org.deegree.geometry.primitive.Point类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.deegree.geometry.primitive.Point类的一些代码示例,展示了Point类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Point类的具体详情如下:
包路径:org.deegree.geometry.primitive.Point
类名称:Point

Point介绍

[英]0-dimensional primitive.
[中]零维原语。

代码示例

代码示例来源:origin: deegree/deegree3

@Override
public Coordinate getCoordinateCopy( int index ) {
  Point point = points.get( index );
  return new Coordinate( point.get0(), point.get1(), point.get2() );
}

代码示例来源:origin: deegree/deegree3

@Override
public boolean equals( Geometry geometry ) {
  if ( !( geometry instanceof Point ) ) {
    return false;
  }
  double[] coordinates = ( (Point) geometry ).getAsArray();
  if ( coordinates.length != this.coordinates.length ) {
    return false;
  }
  for ( int i = 0; i < coordinates.length; i++ ) {
    if ( !( coordinates[i] == this.coordinates[i] ) ) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: deegree/deegree3

@Override
public int getCoordinateDimension() {
  return min.getCoordinateDimension();
}

代码示例来源:origin: deegree/deegree3

@Override
protected com.vividsolutions.jts.geom.Polygon buildJTSGeometry() {
  Points points = new PackedPoints( crs, new double[] { min.get0(), min.get1(), max.get0(), min.get1(),
                             max.get0(), max.get1(), min.get0(), max.get1(),
                             min.get0(), min.get1() }, 2 );
  LinearRing shell = jtsFactory.createLinearRing( ( points ) );
  return jtsFactory.createPolygon( shell, null );
}

代码示例来源:origin: deegree/deegree3

private static Points move( Points points, double offx, double offy ) {
  List<Point> movedPoints = new ArrayList<Point>( points.size() );
  GeometryFactory fac = new GeometryFactory();
  for ( Point point : points ) {
    double[] movedCoordinates = new double[] { point.get0() + offx, point.get1() + offy };
    movedPoints.add( fac.createPoint( point.getId(), movedCoordinates, point.getCoordinateSystem() ) );
  }
  return new PointsList( movedPoints );
}

代码示例来源:origin: deegree/deegree3

/**
 * @param bbox
 *            the bbox to set
 */
public final void setBbox( Envelope bbox ) {
  if ( bbox == null ) {
    throw new NullPointerException( "Bbox may not be null" );
  }
  this.bbox = bbox;
  Point p = bbox.getCentroid();
  double[] min = bbox.getMin().getAsArray();
  double[] max = bbox.getMax().getAsArray();
  position = new float[] { (float) p.get0(), (float) p.get1(),
              (float) ( ( p.getCoordinateDimension() == 3 ) ? p.get2() : 0 ) };
  if ( bbox.getMin().getCoordinateDimension() == 2 ) {
    min = new double[] { min[0], min[1], 0 };
  }
  if ( bbox.getMax().getCoordinateDimension() == 2 ) {
    max = new double[] { max[0], max[1], 0 };
  }
  this.error = (float) Vectors3d.length( Vectors3d.sub( max, min ) );
  this.height = (float) bbox.getSpan1();
  this.groundLevel = (float) min[2];
}

代码示例来源:origin: deegree/deegree3

Point max = env.getMax();
ICRS crs = env.getCoordinateSystem();
if ( min.equals( max ) ) {
  return fac.createPoint( null, min.getAsArray(), crs );
  if ( min.get0() == max.get0() || min.get1() == max.get1() ) {
    Points points = new PointsArray( min, max );
    return fac.createLineString( null, crs, points );
  double[] points = new double[] { min.get0(), min.get1(), max.get0(), min.get1(), max.get0(), max.get1(),
                  min.get0(), max.get1(), min.get0(), min.get1() };
  Curve ls = fac.createLineString( null, crs, new PackedPoints( null, points, 2 ) );
  Ring exteriorRing = fac.createRing( null, crs, Collections.singletonList( ls ) );

代码示例来源:origin: deegree/deegree3

/**
 * transforms the submitted point to the target coordinate reference system
 * 
 * @throws TransformationException
 */
private Point transform( Point geo, Transformation trans )
            throws TransformationException {
  Point3d coord = new Point3d( geo.get0(), geo.get1(), geo.get2() );
  Point3d result = new Point3d( coord );
  result = trans.doTransform( coord );
  if ( Double.isNaN( geo.get2() ) ) {
    return geomFactory.createPoint( geo.getId(), new double[] { result.x, result.y }, getTargetCRS() );
  } else if ( trans.getSourceCRS().getDimension() == 2 && trans.getTargetCRS().getDimension() == 2 ) {
    // pass the 3rd coordinate if exist and dimension of source and target CRS is 2
    result.z = geo.get2();
  }
  return geomFactory.createPoint( geo.getId(), new double[] { result.x, result.y, result.z }, getTargetCRS() );
}

代码示例来源:origin: deegree/deegree3

Point p0Shifted = new DefaultPoint( null, p0.getCoordinateSystem(), p0.getPrecision(),
                  new double[] { p0.get0() - minOrd0, p0.get1() - minOrd1 } );
Point p1Shifted = new DefaultPoint( null, p1.getCoordinateSystem(), p1.getPrecision(),
                  new double[] { p1.get0() - minOrd0, p1.get1() - minOrd1 } );
Point p2Shifted = new DefaultPoint( null, p2.getCoordinateSystem(), p2.getPrecision(),
                  new double[] { p2.get0() - minOrd0, p2.get1() - minOrd1 } );
Vector3d a = new Vector3d( p0Shifted.get0(), p0Shifted.get1(), p0Shifted.get2() );
Vector3d b = new Vector3d( p1Shifted.get0(), p1Shifted.get1(), p1Shifted.get2() );
Vector3d c = new Vector3d( p2Shifted.get0(), p2Shifted.get1(), p2Shifted.get2() );
circle.y += minOrd1;
return geomFac.createPoint( null, new double[] { circle.x, circle.y }, p0Shifted.getCoordinateSystem() );

代码示例来源:origin: deegree/deegree3

private void exportAsPos( Point point )
            throws XMLStreamException, UnknownCRSException, TransformationException {
  writer.writeStartElement( gmlNs, "pos" );
  double[] ordinates = getTransformedCoordinate( point.getCoordinateSystem(), point.getAsArray() );
  writer.writeCharacters( formatter.format( ordinates[0] ) );
  for ( int i = 1; i < ordinates.length; i++ ) {
    writer.writeCharacters( " " + formatter.format( ordinates[i] ) );
  }
  writer.writeEndElement();
}

代码示例来源:origin: deegree/deegree3

/**
 * @param dts
 * @param sceneEnvelope
 * @param toLocalCRS
 * @param adapter
 * @return
 */
private Envelope handleColormapDataset( ColormapDatasetConfig dts, Envelope sceneEnvelope, double[] toLocalCRS ) {
  float[] maxColor = parseColor( dts.getMaxColor(), MAX_DEFAULT );
  float[] minColor = parseColor( dts.getMinColor(), MIN_DEFAULT );
  float[] heightColor = parseColor( dts.getHeightISOColor(), HEIGHT_DEFAULT );
  double zMax = dts.getMaxZValue() == null ? sceneEnvelope.getMax().get2() : dts.getMaxZValue();
  double zMin = dts.getMinZValue() == null ? sceneEnvelope.getMin().get2() : dts.getMinZValue();
  Colormap result = new Colormap( (float) zMin, (float) zMax, minColor, maxColor, heightColor );
  if ( LOG.isDebugEnabled() ) {
    LOG.debug( "Configured colormap: " + dts.getTitle() + " | " + result.toString() );
  }
  double[] min = Arrays.copyOf( sceneEnvelope.getMin().getAsArray(), 3 );
  double[] max = Arrays.copyOf( sceneEnvelope.getMax().getAsArray(), 3 );
  min[0] += toLocalCRS[0];
  min[1] += toLocalCRS[1];
  max[0] += toLocalCRS[0];
  max[1] += toLocalCRS[1];
  super.addConstraint( dts.getTitle(), result,
             geomFac.createEnvelope( min, max, sceneEnvelope.getCoordinateSystem() ) );
  return sceneEnvelope;
}

代码示例来源:origin: deegree/deegree3

if ( !p.getStartPoint().equals( p.getEndPoint() ) ) {
  LOG.warn( "Found ring that is not closed. Repairing it." );
  double[] coords = new double[( p.size() + 1 ) * p.getDimension()];
  int i = 0;
  for ( Point pt : p ) {
    for ( int dim = 0; dim < pt.getCoordinateDimension(); dim++ ) {
      coords[i++] = pt.get( dim );
    coords[i++] = p.get( 0 ).get( dim );

代码示例来源:origin: deegree/deegree3

@Override
  public double get2() {
    return getReferencedObject().get2();
  }
}

代码示例来源:origin: deegree/deegree3

@Override
public Envelope expandEnvelope( Envelope env ) {
  for ( Point p : this ) {
    env.expandToInclude( p.get0(), p.get1() );
  }
  return env;
}

代码示例来源:origin: deegree/deegree3

double[] min = bbox.getMin().getAsArray();
double[] max = bbox.getMax().getAsArray();
position = new float[] { (float) p.get0(), (float) p.get1(),
            (float) ( ( p.getCoordinateDimension() == 3 ) ? p.get2() : 0 ) };
if ( bbox.getMin().getCoordinateDimension() == 2 ) {
  min = new double[] { min[0], min[1], 0 };
if ( bbox.getMax().getCoordinateDimension() == 2 ) {
  max = new double[] { max[0], max[1], 0 };

代码示例来源:origin: deegree/deegree3

/**
 * transforms the list of points
 * 
 * @throws TransformationException
 */
private Points transform( Points points, Transformation trans )
            throws TransformationException {
  List<Point> result = new ArrayList<Point>( points.size() );
  for ( Point point : points ) {
    Point3d coord = new Point3d( point.get0(), point.get1(), point.get2() );
    Point3d tmp = new Point3d( coord );
    tmp = trans.doTransform( coord );
    if ( Double.isNaN( point.get2() ) ) {
      result.add( geomFactory.createPoint( point.getId(), new double[] { tmp.x, tmp.y }, getTargetCRS() ) );
    } else {
      // pass the 3rd coordinate if exist and dimension of source and target CRS is 2
      if ( trans.getSourceCRS().getDimension() == 2 && trans.getTargetCRS().getDimension() == 2 ) {
        tmp.z = point.get2();
      }
      result.add( geomFactory.createPoint( point.getId(), new double[] { tmp.x, tmp.y, tmp.z },
                         getTargetCRS() ) );
    }
  }
  return new PointsList( result );
}

代码示例来源:origin: deegree/deegree3

private void exportCoord( Point point )
            throws XMLStreamException, TransformationException, UnknownCRSException {
  double[] ords = getTransformedCoordinate( point.getCoordinateSystem(), point.getAsArray() );
  writer.writeStartElement( "gml", "coord", GML21NS );
  writer.writeStartElement( "gml", "X", GML21NS );
  writer.writeCharacters( formatter.format( ords[0] ) );
  writer.writeEndElement();
  if ( ords.length > 1 ) {
    writer.writeStartElement( "gml", "Y", GML21NS );
    writer.writeCharacters( formatter.format( ords[1] ) );
    writer.writeEndElement();
    if ( ords.length > 2 ) {
      writer.writeStartElement( "gml", "Z", GML21NS );
      writer.writeCharacters( formatter.format( ords[2] ) );
      writer.writeEndElement();
    }
  }
  writer.writeEndElement(); // </gml:coord>
}

代码示例来源:origin: deegree/deegree3

double[] min = datasetEnvelope.getMin().getAsArray();
    double[] max = datasetEnvelope.getMax().getAsArray();
    double[] tMin = Arrays.copyOf( min, 3 );
    double[] tMax = Arrays.copyOf( max, 3 );
    tMin[2] = sceneEnvelope.getMin().get2();
    tMax[2] = sceneEnvelope.getMax().get2();
    datasetEnvelope = geomFac.createEnvelope( tMin, tMax, datasetEnvelope.getCoordinateSystem() );
double[] min = constraintEnv.getMin().getAsArray();
double[] max = constraintEnv.getMax().getAsArray();
double[] tMin = Arrays.copyOf( min, min.length );
double[] tMax = Arrays.copyOf( max, max.length );

代码示例来源:origin: deegree/deegree3

private static double getEnvDepth( Envelope env ) {
  double result = Double.NaN;
  if ( env.getCoordinateDimension() == 3 ) {
    result = env.getMax().get2() - env.getMin().get2();
  }
  return result;
}

代码示例来源:origin: deegree/deegree3

@Override
public void getCoordinate( int index, Coordinate coord ) {
  if ( index < points.size() && index >= 0 ) {
    Point point = points.get( index );
    coord.x = point.get0();
    coord.y = point.get1();
    coord.z = point.get2();
  }
}

相关文章