private Envelope getDefaultBBox() { return new GeometryFactory().createEnvelope( new double[] { -sphereSize, -sphereSize, -sphereSize }, new double[] { sphereSize, sphereSize, sphereSize }, null ); }
private Polygon getLegendRect( int xpos, int ypos, int xsize, int ysize ) { Point p1 = geofac.createPoint( null, xpos, ypos, mapcs ); Point p2 = geofac.createPoint( null, xpos + xsize, ypos, mapcs ); Point p3 = geofac.createPoint( null, xpos + xsize, ypos - ysize, mapcs ); Point p4 = geofac.createPoint( null, xpos, ypos - ysize, mapcs ); List<Point> ps = new ArrayList<Point>( 5 ); ps.add( p1 ); ps.add( p2 ); ps.add( p3 ); ps.add( p4 ); ps.add( p1 ); return geofac.createPolygon( null, mapcs, geofac.createLinearRing( null, null, geofac.createPoints( ps ) ), null ); }
private LineString getLegendLine( int xpos, int ypos, int xsz, int ysz ) { Point p1 = geofac.createPoint( null, xpos, ypos - ysz, mapcs ); Point p2 = geofac.createPoint( null, xpos + xsz / 3, ypos - ysz / 3, mapcs ); Point p3 = geofac.createPoint( null, xpos + xsz / 3 * 2, ypos - ysz / 3 * 2, mapcs ); Point p4 = geofac.createPoint( null, xpos + xsz, ypos, mapcs ); List<Point> ps = new ArrayList<Point>( 4 ); ps.add( p1 ); ps.add( p2 ); ps.add( p3 ); ps.add( p4 ); return geofac.createLineString( null, mapcs, geofac.createPoints( ps ) ); }
/** * @param ps * @param b * @param index * @throws SQLException */ private Envelope getEnvelope( float[] location, float width, float height, float depth ) { return geomFac.createEnvelope( new double[] { location[0], location[1], location[2] }, new double[] { location[0] + width, location[1] + depth, location[2] + height }, null ); }
/** * Creates a new {@link GeometryValidator} which performs callbacks on the given * {@link GeometryValidationEventHandler} in case of errors. * * @param eventHandler * callback handler for errors, must not be <code>null</code> */ public GeometryValidator( GeometryValidationEventHandler eventHandler ) { linearizer = new CurveLinearizer( new org.deegree.geometry.GeometryFactory() ); crit = new NumPointsCriterion( 150 ); jtsFactory = new GeometryFactory(); this.eventHandler = eventHandler; }
/** * @param env * @return a polygon */ public static Polygon envelopeToPolygon( Envelope env ) { GeometryFactory fac = new GeometryFactory(); Point a = env.getMin(); Point b = fac.createPoint( null, a.get0() + env.getSpan0(), a.get1(), env.getCoordinateSystem() ); Point c = env.getMax(); Point d = fac.createPoint( null, a.get0(), a.get1() + env.getSpan1(), env.getCoordinateSystem() ); LinearRing ring = fac.createLinearRing( null, env.getCoordinateSystem(), new PointsArray( a, b, c, d, a ) ); return fac.createPolygon( null, env.getCoordinateSystem(), ring, null ); }
GeometryFactory fac = new GeometryFactory(); if ( geom instanceof Point ) { Point p = (Point) geom; return fac.createPoint( geom.getId(), new double[] { p.get0() + offx, p.get1() + offy }, p.getCoordinateSystem() ); ps.add( (Point) move( p, offx, offy ) ); return fac.createLineString( geom.getId(), c.getCoordinateSystem(), new PointsList( ps ) ); LinearRing movedExteriorRing = null; if ( exterior != null ) { movedExteriorRing = fac.createLinearRing( exterior.getId(), exterior.getCoordinateSystem(), move( exterior.getAsLineString().getControlPoints(), List<Ring> movedInteriorRings = new ArrayList<Ring>( interiorRings.size() ); for ( Ring interior : interiorRings ) { movedInteriorRings.add( fac.createLinearRing( interior.getId(), interior.getCoordinateSystem(), move( interior.getAsLineString().getControlPoints(), offx, offy ) ) ); movedPatches.add( fac.createPolygonPatch( movedExteriorRing, movedInteriorRings ) ); } else { throw new UnsupportedOperationException( "Cannot move non-planar surface patches." ); return fac.createSurface( geom.getId(), movedPatches, geom.getCoordinateSystem() );
/** * @return an interior point of this geometry */ public Point getInteriorPoint() { Coordinate coord = new InteriorPointArea( getJTSGeometry() ).getInteriorPoint(); return new GeometryFactory().createPoint( null, coord.x, coord.y, crs ); }
double[] coords = parseCoordType( xmlStream ); points.add( geomFac.createPoint( null, coords, crs ) ); } else { String msg = "Error in 'gml:Envelope' element."; Envelope envelope = geomFac.createEnvelope( points.get( 0 ).getAsArray(), points.get( 1 ).getAsArray(), crs ); idContext.addObject( envelope ); return envelope;
/** * Calculates the points inside the geometry and inside the view port. First the passed geometry is clipped * by the view port. A multipolygon may result. For each of the polygon in this multipolygon one interior point * is created * * @param geom to create labels for, must not be <code>null</code> and in the same CRS as the viewPort * @return a MultiPoint with all calculated labels */ MultiPoint calculateInteriorPoints( final Geometry geom ) { if ( geom == null ) return null; Geometry clippedGeometry = clipGeometry( geom, viewPort ); List<Point> points = new ArrayList<Point>(); if ( clippedGeometry != null && clippedGeometry instanceof DefaultSurface ) { points.add( ( (DefaultSurface) clippedGeometry ).getInteriorPoint() ); } if ( clippedGeometry != null && clippedGeometry instanceof MultiPolygon ) { for ( Polygon p : ( (MultiPolygon) clippedGeometry ) ) { if ( p instanceof DefaultSurface ) { points.add( ( (DefaultSurface) p ).getInteriorPoint() ); } } } return new GeometryFactory().createMultiPoint( null, geom.getCoordinateSystem(), points ); }
private LinkedList<Polygon> fromTriangleStrip( double[][] points ) { LinkedList<Point> ps = new LinkedList<Point>(); for ( double[] p : points ) { ps.add( fac.createPoint( null, p, crs ) ); } LinkedList<Polygon> ss = new LinkedList<Polygon>(); while ( ps.size() > 2 ) { LinkedList<Point> ring = new LinkedList<Point>(); ring.add( ps.get( 0 ) ); ring.add( ps.get( 1 ) ); ring.add( ps.get( 2 ) ); ring.add( ring.getFirst() ); ps.poll(); LinearRing r = fac.createLinearRing( null, crs, new PointsList( ring ) ); ss.add( fac.createPolygon( null, crs, r, null ) ); } return ss; }
private Point getPoint( Coordinate jtsCoord, ICRS crs ) { if ( jtsCoord == null ) { return null; } double[] coords = null; if ( jtsCoord.z != Double.NaN ) { coords = new double[] { jtsCoord.x, jtsCoord.y, jtsCoord.z }; } else if ( jtsCoord.y != Double.NaN ) { coords = new double[] { jtsCoord.x, jtsCoord.y }; } else { coords = new double[] { jtsCoord.x }; } return geomFac.createPoint( null, coords, crs ); }
ICRS crs = env.getCoordinateSystem(); if ( min.equals( max ) ) { return fac.createPoint( null, min.getAsArray(), crs ); return fac.createLineString( null, crs, points ); Curve ls = fac.createLineString( null, crs, new PackedPoints( null, points, 2 ) ); Ring exteriorRing = fac.createRing( null, crs, Collections.singletonList( ls ) ); return fac.createPolygon( null, crs, exteriorRing, null );
private MultiPoint readMultipoint( ByteBuffer buffer ) { int num = buffer.getInt(); LinkedList<Point> list = new LinkedList<Point>(); for ( int i = 0; i < num; ++i ) { list.add( fac.createPoint( null, buffer.getDouble(), buffer.getDouble(), crs ) ); } return fac.createMultiPoint( null, crs, list ); }
outer = fac.createLinearRing( null, crs, p ); } else { LinearRing ring = fac.createLinearRing( null, crs, p ); Polygon outerP = fac.createPolygon( null, crs, outer, null ); Polygon innerP = fac.createPolygon( null, crs, ring, null ); if ( outerP.contains( innerP ) ) { inners.add( ring ); polys.add( fac.createPolygon( null, crs, outer, inners ) ); inners = new LinkedList<Ring>(); } else { polys.add( fac.createPolygon( null, crs, outer, null ) ); polys.add( fac.createPolygon( null, crs, outer, inners ) ); return fac.createMultiPolygon( null, crs, polys );
private LinearRing fromRing( double[][] points ) { LinkedList<Point> ps = new LinkedList<Point>(); for ( double[] p : points ) { ps.add( fac.createPoint( null, p, crs ) ); } // may be expensive if ( ps.getFirst() != ps.getLast() ) { LOG.debug( "Ring was not closed as required by the shape file spec!" ); LOG.debug( "Trying to recover anyway." ); ps.add( ps.getFirst() ); } return fac.createLinearRing( null, crs, new PointsList( ps ) ); }
if ( outerRingMode ) { LOG.trace( "Finishing with outer ring mode." ); ss.add( fac.createPolygon( null, crs, outerRing, innerRings ) ); innerRings.clear(); outerRing = null; ring = fromRing( ps[i] ); if ( !unknownRingMode ) { ss.add( fac.createPolygon( null, crs, ring, null ) ); } else { if ( isCCW( ring ) ) { if ( unknownOuterRing == null ) { while ( unknownInnerRings.size() != 0 ) { ss.add( fac.createPolygon( null, crs, unknownInnerRings.poll(), null ) ); ss.add( fac.createPolygon( null, crs, unknownOuterRing, unknownInnerRings ) ); return null; return fac.createMultiPolygon( null, crs, ss );
linearizedInteriorRings.add( (Ring) curveLinearizer.linearize( interiorRing, crit ) ); linearizedSurface = (T) geomFac.createPolygon( polygon.getId(), polygon.getCoordinateSystem(), linearizedExteriorRing, linearizedInteriorRings ); break; linearizedSurface = (T) geomFac.createPolyhedralSurface( surface.getId(), surface.getCoordinateSystem(), linearizedPatches ); break; linearizedSurface = (T) geomFac.createSurface( surface.getId(), linearizedPatches, surface.getCoordinateSystem() ); break;
ICRS normalCRS = determineActiveCRS( xmlStream, defaultCRS ); double[] coords = parseDoubleList( xmlStream ); normals.add( geomFac.createPoint( null, coords, normalCRS ) ); xmlStream.nextTag(); return geomFac.createArcStringByBulge( points, bulges, geomFac.createPoints( normals ) );
private LinearRing transform( Ring ring, Transformation trans ) throws TransformationException { if ( ring != null ) { // TODO DefaultRing.getAsLineString currently returns an UnsupportedOpertionException // interior.getAsLineString().getControlPoints(), Points cP = ring.getControlPoints(); Points tcP = transform( cP, trans ); return geomFactory.createLinearRing( ring.getId(), getTargetCRS(), tcP ); } return null; }