private CoordinateSequence toCoordinateSequence(OsmEntityProvider resolver) throws EntityNotFoundException { CoordinateSequenceFactory csf = factory.getCoordinateSequenceFactory(); int len = this.getLength(); CoordinateSequence points = csf.create(len, 2); int n = 0; for (int i = 0; i < this.segments.size(); i++) { WaySegment segment = this.segments.get(i); OsmWay way = segment.getWay(); for (int k = 0; k < way.getNumberOfNodes(); k++) { if (k > 0 || i == 0) { OsmNode node = resolver.getNode(segment.getNodeId(k)); points.setOrdinate(n, 0, node.getLongitude()); points.setOrdinate(n, 1, node.getLatitude()); n++; } } } return points; }
/** * Does what it says, reverses the order of the Coordinates in the ring. * <p> * This is different then lr.reverses() in that a copy is produced using a * new coordinate sequence. * </p> * * @param lr The ring to reverse. * @return A new ring with the reversed Coordinates. */ public static final LinearRing reverseRing(LinearRing lr) { GeometryFactory gf = lr.getFactory(); CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory(); CoordinateSequence csOrig = lr.getCoordinateSequence(); int numPoints = csOrig.size(); int dimensions = csOrig.getDimension(); CoordinateSequence csNew = csf.create(numPoints, dimensions); for (int i = 0; i < numPoints; i++) { for (int j = 0; j < dimensions; j++) { csNew.setOrdinate(numPoints - 1 - i, j, csOrig.getOrdinate(i, j)); } } return gf.createLinearRing(csNew); }
public static IShape buildRectangle(final double width, final double height, final ILocation location) { final Coordinate[] points = new Coordinate[5]; final double x = location == null ? 0 : location.getX(); final double y = location == null ? 0 : location.getY(); final double z = location == null ? 0 : location.getZ(); points[4] = new GamaPoint(x - width / 2.0, y + height / 2.0, z); points[3] = new GamaPoint(x + width / 2.0, y + height / 2.0, z); points[2] = new GamaPoint(x + width / 2.0, y - height / 2.0, z); points[1] = new GamaPoint(x - width / 2.0, y - height / 2.0, z); points[0] = new GamaPoint(x - width / 2.0, y + height / 2.0, z); final CoordinateSequenceFactory fact = GamaGeometryFactory.COORDINATES_FACTORY; final CoordinateSequence cs = fact.create(points); final LinearRing geom = GeometryUtils.GEOMETRY_FACTORY.createLinearRing(cs); final Polygon p = GeometryUtils.GEOMETRY_FACTORY.createPolygon(geom, null); return new GamaShape(p); }
protected void init( SimpleMonetDBFeatureSource featureSource, SimpleFeatureType featureType, Hints hints ) { // init base fields this.featureSource = featureSource; this.dataStore = featureSource.getDataStore(); this.featureType = featureType; this.tx = featureSource.getTransaction(); this.hints = hints; //grab a geometry factory... check for a special hint geometryFactory = (GeometryFactory) hints.get(Hints.JTS_GEOMETRY_FACTORY); if (geometryFactory == null) { // look for a coordinate sequence factory CoordinateSequenceFactory csFactory = (CoordinateSequenceFactory) hints.get(Hints.JTS_COORDINATE_SEQUENCE_FACTORY); if (csFactory != null) { geometryFactory = new GeometryFactory(csFactory); } } if (geometryFactory == null) { geometryFactory = JTSFactoryFinder.getGeometryFactory(null); } builder = new SimpleFeatureBuilder(featureType); }
@Override CoordinateSequenceFactory getCSFactory() { return new PackedCoordinateSequenceFactory(); }
@Override CoordinateSequenceFactory getCSFactory() { return CoordinateArraySequenceFactory.instance(); }
/** * <p>Constructor for ExtendedGeometryFactory.</p> * * @param coordinateSequenceFactory a {@link com.vividsolutions.jts.geom.CoordinateSequenceFactory} object. */ public ExtendedGeometryFactory(CoordinateSequenceFactory coordinateSequenceFactory) { super(coordinateSequenceFactory); }
/** * <p>Constructor for ExtendedGeometryFactory.</p> * * @param precisionModel a {@link com.vividsolutions.jts.geom.PrecisionModel} object. * @param SRID a int. * @param coordinateSequenceFactory a {@link com.vividsolutions.jts.geom.CoordinateSequenceFactory} object. */ public ExtendedGeometryFactory(PrecisionModel precisionModel, int SRID, CoordinateSequenceFactory coordinateSequenceFactory) { super(precisionModel, SRID, coordinateSequenceFactory); }
abstract CoordinateSequenceFactory getCSFactory();