Search in sources :

Example 56 with Coordinate

use of com.vividsolutions.jts.geom.Coordinate in project incubator-rya by apache.

the class GeoWaveGTQueryTest method ingestCannedData.

private static void ingestCannedData() throws IOException {
    final List<SimpleFeature> points = new ArrayList<>();
    System.out.println("Building SimpleFeatures from canned data set...");
    for (final Entry<String, Coordinate> entry : CANNED_DATA.entrySet()) {
        System.out.println("Added point: " + entry.getKey());
        points.add(buildSimpleFeature(entry.getKey(), entry.getValue()));
    }
    System.out.println("Ingesting canned data...");
    try (final IndexWriter<SimpleFeature> indexWriter = dataStore.createWriter(ADAPTER, INDEX)) {
        for (final SimpleFeature sf : points) {
            indexWriter.write(sf);
        }
    }
    System.out.println("Ingest complete.");
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) ArrayList(java.util.ArrayList) SimpleFeature(org.opengis.feature.simple.SimpleFeature)

Example 57 with Coordinate

use of com.vividsolutions.jts.geom.Coordinate in project incubator-rya by apache.

the class MongoIndexerDeleteIT method populateRya.

private void populateRya(final SailRepositoryConnection conn) throws Exception {
    final ValueFactory VF = new ValueFactoryImpl();
    // geo 2x2 points
    final GeometryFactory GF = new GeometryFactory();
    for (int x = 0; x <= 1; x++) {
        for (int y = 0; y <= 1; y++) {
            final Geometry geo = GF.createPoint(new Coordinate(x + .5, y + .5));
            final RyaStatement stmnt = statement(geo);
            final Statement statement = RyaToRdfConversions.convertStatement(stmnt);
            conn.add(statement);
        }
    }
    // freetext
    final URI person = VF.createURI("http://example.org/ontology/Person");
    String uuid;
    uuid = "urn:people";
    conn.add(VF.createURI(uuid), RDF.TYPE, person);
    conn.add(VF.createURI(uuid), RDFS.LABEL, VF.createLiteral("Alice Palace Hose", VF.createURI("http://www.w3.org/2001/XMLSchema#string")));
    conn.add(VF.createURI(uuid), RDFS.LABEL, VF.createLiteral("Bob Snob Hose", "en"));
    // temporal
    final TemporalInstant instant = new TemporalInstantRfc3339(1, 2, 3, 4, 5, 6);
    conn.add(VF.createURI("foo:time"), VF.createURI("Property:atTime"), VF.createLiteral(instant.toString()));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) Coordinate(com.vividsolutions.jts.geom.Coordinate) Statement(org.openrdf.model.Statement) RyaStatement(org.apache.rya.api.domain.RyaStatement) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) RyaStatement(org.apache.rya.api.domain.RyaStatement) ValueFactory(org.openrdf.model.ValueFactory) TemporalInstant(org.apache.rya.indexing.TemporalInstant) URI(org.openrdf.model.URI)

Example 58 with Coordinate

use of com.vividsolutions.jts.geom.Coordinate in project alliance by codice.

the class NitfImageTransformer method getPolygonForSegment.

private Polygon getPolygonForSegment(ImageSegment segment, GeometryFactory geomFactory) {
    Coordinate[] coords = new Coordinate[5];
    ImageCoordinates imageCoordinates = segment.getImageCoordinates();
    coords[0] = new Coordinate(imageCoordinates.getCoordinate00().getLongitude(), imageCoordinates.getCoordinate00().getLatitude());
    coords[4] = new Coordinate(coords[0]);
    coords[1] = new Coordinate(imageCoordinates.getCoordinate0MaxCol().getLongitude(), imageCoordinates.getCoordinate0MaxCol().getLatitude());
    coords[2] = new Coordinate(imageCoordinates.getCoordinateMaxRowMaxCol().getLongitude(), imageCoordinates.getCoordinateMaxRowMaxCol().getLatitude());
    coords[3] = new Coordinate(imageCoordinates.getCoordinateMaxRow0().getLongitude(), imageCoordinates.getCoordinateMaxRow0().getLatitude());
    LinearRing externalRing = geomFactory.createLinearRing(coords);
    return geomFactory.createPolygon(externalRing, null);
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) ImageCoordinates(org.codice.imaging.nitf.core.image.ImageCoordinates) LinearRing(com.vividsolutions.jts.geom.LinearRing)

Example 59 with Coordinate

use of com.vividsolutions.jts.geom.Coordinate in project alliance by codice.

the class LinestringGeometrySubsampler method apply.

@Override
public Geometry apply(Geometry geometry, Context context) {
    if (!(geometry instanceof LineString)) {
        return geometry;
    }
    if (context.getSubsampleCount() == null) {
        throw new IllegalStateException("subsampleCount must be set in the GeometryOperator.Context");
    }
    int subsampleCount = context.getSubsampleCount();
    Coordinate[] input = geometry.getCoordinates();
    int inputSize = input.length;
    if (input.length <= subsampleCount) {
        return geometry;
    }
    Coordinate[] output = new Coordinate[subsampleCount];
    for (int i = 0; i < subsampleCount; i++) {
        output[i] = input[i * inputSize / subsampleCount];
    }
    return new GeometryFactory().createLineString(output);
}
Also used : GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) LineString(com.vividsolutions.jts.geom.LineString) Coordinate(com.vividsolutions.jts.geom.Coordinate)

Example 60 with Coordinate

use of com.vividsolutions.jts.geom.Coordinate in project alliance by codice.

the class NsiliFilterFactory method convertWktToBqs.

public String convertWktToBqs(String wkt) {
    WKTReader wktReader = new WKTReader(GEOMETRY_FACTORY);
    Geometry geometry;
    try {
        geometry = wktReader.read(wkt);
    } catch (ParseException e) {
        LOGGER.debug("Unable to parse WKT String {}", wkt, e);
        return NsiliFilterDelegate.EMPTY_STRING;
    }
    if (geometry.getCoordinates() == null || StringUtils.isBlank(geometry.getGeometryType())) {
        return NsiliFilterDelegate.EMPTY_STRING;
    }
    StringBuilder result = new StringBuilder(geometry.getGeometryType().toUpperCase() + LP);
    Coordinate[] coordinates = geometry.getCoordinates();
    for (Coordinate coordinate : coordinates) {
        result.append(coordinate.y + COMMA + coordinate.x + COMMA);
    }
    return result.toString().substring(0, result.toString().length() - 1) + RP;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) Coordinate(com.vividsolutions.jts.geom.Coordinate) ParseException(com.vividsolutions.jts.io.ParseException) WKTReader(com.vividsolutions.jts.io.WKTReader)

Aggregations

Coordinate (com.vividsolutions.jts.geom.Coordinate)336 LineString (com.vividsolutions.jts.geom.LineString)70 Geometry (com.vividsolutions.jts.geom.Geometry)67 ArrayList (java.util.ArrayList)65 Test (org.junit.Test)60 Point (com.vividsolutions.jts.geom.Point)52 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)48 Polygon (com.vividsolutions.jts.geom.Polygon)30 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)27 SimpleFeature (org.opengis.feature.simple.SimpleFeature)23 LinearRing (com.vividsolutions.jts.geom.LinearRing)22 Vertex (org.opentripplanner.routing.graph.Vertex)22 Envelope (com.vividsolutions.jts.geom.Envelope)21 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)20 Edge (org.opentripplanner.routing.graph.Edge)19 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)19 CoordinateSequence (com.vividsolutions.jts.geom.CoordinateSequence)14 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)13 File (java.io.File)11 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)11