Search in sources :

Example 11 with Geometry

use of org.opengis.geometry.Geometry in project ddf by codice.

the class CopyFilterDelegateTest method testSpatialOverlaps.

@Test
public void testSpatialOverlaps() {
    Geometry polygonGeometry = wktToGeometry(POLYGON_WKT);
    assertFilterException(FF.overlaps(TEST_PROPERTY_VALUE, polygonGeometry));
}
Also used : Geometry(org.opengis.geometry.Geometry) Test(org.junit.Test)

Example 12 with Geometry

use of org.opengis.geometry.Geometry in project ddf by codice.

the class CopyFilterDelegateTest method testSpatialDisjoint.

@Test
public void testSpatialDisjoint() {
    Geometry polygonGeometry = wktToGeometry(POLYGON_WKT);
    assertFilterException(FF.disjoint(TEST_PROPERTY_VALUE, polygonGeometry));
}
Also used : Geometry(org.opengis.geometry.Geometry) Test(org.junit.Test)

Example 13 with Geometry

use of org.opengis.geometry.Geometry in project ddf by codice.

the class CopyFilterDelegateTest method testSpatialTouches.

@Test
public void testSpatialTouches() {
    Geometry polygonGeometry = wktToGeometry(POLYGON_WKT);
    assertFilterException(FF.touches(TEST_PROPERTY_VALUE, polygonGeometry));
}
Also used : Geometry(org.opengis.geometry.Geometry) Test(org.junit.Test)

Example 14 with Geometry

use of org.opengis.geometry.Geometry in project ddf by codice.

the class OpenSearchQuery method addSpatialFilter.

private void addSpatialFilter(SpatialFilter spatialFilter) {
    Geometry geometry = spatialFilter.getGeometry();
    if (geometry != null) {
        Filter filter = FILTER_FACTORY.intersects(Metacard.ANY_GEO, geometry);
        LOGGER.debug("Adding spatial filter");
        filters.add(filter);
    }
}
Also used : Geometry(org.opengis.geometry.Geometry) SpatialFilter(ddf.catalog.impl.filter.SpatialFilter) TemporalFilter(ddf.catalog.impl.filter.TemporalFilter) SpatialDistanceFilter(ddf.catalog.impl.filter.SpatialDistanceFilter) PolygonSpatialFilter(org.codice.ddf.opensearch.query.filter.PolygonSpatialFilter) Filter(org.opengis.filter.Filter) BBoxSpatialFilter(org.codice.ddf.opensearch.query.filter.BBoxSpatialFilter)

Example 15 with Geometry

use of org.opengis.geometry.Geometry in project ddf by codice.

the class OpenSearchQueryTest method testWktParserPolygon.

@Test
@Ignore
public void testWktParserPolygon() throws Exception {
    String geometryWkt = "POLYGON(( 0 10, 0 30, 20 30, 20 10, 0 10 ))";
    GeometryBuilder builder = new GeometryBuilder(DefaultGeographicCRS.WGS84);
    WKTParser parser = new WKTParser(builder);
    // This fixed the NPE in parser.parse() - seems GeoTools has bug with
    // keeping the CRS hint set ...
    parser.setFactory(new PrimitiveFactoryImpl(DefaultGeographicCRS.WGS84));
    Geometry geometry = parser.parse(geometryWkt);
    CoordinateReferenceSystem crs = geometry.getCoordinateReferenceSystem();
    assertNotNull(crs);
    double[] coords = geometry.getCentroid().getCoordinate();
    LOGGER.debug("coords[0] = {},   coords[1] = {}", coords[0], coords[1]);
    // String geometryWkt2 = "POINT( 10 20 )";
    String geometryWkt2 = "POLYGON(( 10 15, 10 25, 15 25, 15 15, 10 15 ))";
    builder = new GeometryBuilder(DefaultGeographicCRS.WGS84);
    WKTParser parser2 = new WKTParser(builder);
    // This fixed the NPE in parser.parse() - seems GeoTools has bug with
    // keeping the CRS hint set ...
    parser2.setFactory(new PrimitiveFactoryImpl(DefaultGeographicCRS.WGS84));
    Geometry geometry2 = parser2.parse(geometryWkt2);
    double[] coords2 = geometry2.getCentroid().getCoordinate();
    LOGGER.debug("coords[0] = {},   coords[1] = {}", coords2[0], coords2[1]);
    // This fails - why?
    assertTrue(geometry.contains(geometry2));
}
Also used : Geometry(org.opengis.geometry.Geometry) PrimitiveFactoryImpl(org.geotools.geometry.jts.spatialschema.geometry.primitive.PrimitiveFactoryImpl) WKTParser(org.geotools.geometry.text.WKTParser) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) GeometryBuilder(org.geotools.geometry.GeometryBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Geometry (org.opengis.geometry.Geometry)28 Test (org.junit.Test)22 Filter (org.opengis.filter.Filter)5 SpatialDistanceFilter (ddf.catalog.impl.filter.SpatialDistanceFilter)4 SpatialFilter (ddf.catalog.impl.filter.SpatialFilter)4 TemporalFilter (ddf.catalog.impl.filter.TemporalFilter)4 JTSGeometryWrapper (ddf.catalog.impl.filter.JTSGeometryWrapper)2 BBoxSpatialFilter (org.codice.ddf.opensearch.query.filter.BBoxSpatialFilter)2 PolygonSpatialFilter (org.codice.ddf.opensearch.query.filter.PolygonSpatialFilter)2 GeometryBuilder (org.geotools.geometry.GeometryBuilder)2 PrimitiveFactoryImpl (org.geotools.geometry.jts.spatialschema.geometry.primitive.PrimitiveFactoryImpl)2 WKTParser (org.geotools.geometry.text.WKTParser)2 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)2 ParseException (com.vividsolutions.jts.io.ParseException)1 WKTReader (com.vividsolutions.jts.io.WKTReader)1 FilterBuilder (ddf.catalog.filter.FilterBuilder)1 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)1 ParseException (java.text.ParseException)1 DefaultFilterVisitor (org.geotools.filter.visitor.DefaultFilterVisitor)1 Ignore (org.junit.Ignore)1