private boolean checkForReferencesOrIds( final Points points ) { boolean hasID = false; for ( final Point p : points ) { if ( p instanceof Reference<?> && !( (Reference<?>) p ).isLocal() ) { hasID = true; break; } else if ( p.getId() != null && p.getId().trim().length() > 0 ) { hasID = true; break; } } return hasID; }
/** * @param multiPoint * @throws XMLStreamException * @throws UnknownCRSException * @throws TransformationException */ public void exportMultiPoint( MultiPoint multiPoint ) throws XMLStreamException, TransformationException, UnknownCRSException { startGeometry( "MultiPoint", multiPoint ); for ( Point point : multiPoint ) { if ( referenceExportStrategy.isObjectExported( point.getId() ) ) { writer.writeEmptyElement( "gml", "pointMember", GML21NS ); writer.writeAttribute( "xlink", XLNNS, "href", "#" + point.getId() ); } else { writer.writeStartElement( "gml", "pointMember", GML21NS ); exportPoint( point ); writer.writeEndElement(); } } writer.writeEndElement(); // </gml:MultiPoint> }
private void exportPointsAsProperties( final Points points ) throws XMLStreamException, UnknownCRSException, TransformationException { for ( final Point point : points ) { writer.writeStartElement( "gml", "pointProperty", gmlNs ); if ( point instanceof Reference<?> && !( (Reference<?>) point ).isLocal() ) { final Reference<?> ref = (Reference<?>) point; writeAttributeWithNS( XLNNS, "href", ref.getURI() ); } else if ( point.getId() != null && referenceExportStrategy.isObjectExported( point.getId() ) ) { writeAttributeWithNS( XLNNS, "href", "#" + point.getId() ); } else { export( point ); } writer.writeEndElement(); } }
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 ); }
/** * 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 ); }
/** * 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() ); }
if ( min.equals( max ) ) { min = new DefaultPoint( min.getId(), min.getCoordinateSystem(), min.getPrecision(), new double[] { min.get0() - 0.0001, min.get1() - 0.0001 } ); if ( min.equals( max ) ) { min = new DefaultPoint( min.getId(), min.getCoordinateSystem(), min.getPrecision(), new double[] { min.get0() - 0.0001, min.get1() - 0.0001 } );