use of com.vividsolutions.jts.geom.Point in project eol-globi-data by jhpoelen.
the class EcoregionFinderImplTest method longhurstProvince.
@Test
public void longhurstProvince() throws EcoregionFinderException {
EcoregionFinder finder = new EcoregionFinderFactoryImpl().createEcoregionFinder(EcoregionType.LONGHURST_BIOGEOGRAPHICAL_PROVINCES);
Point aPointNearFlorida = GeoUtil.getPoint(26.863281, -82.756349);
Map<String, Object> props = findEcoregionProperties(aPointNearFlorida, finder);
assertThat(props.toString(), startsWith("{ProvCode=CARB, ProvDescr=Trades - Caribbean Province, the_geom=MULTIPOLYGON"));
Collection<Ecoregion> ecoregion = finder.findEcoregion(26.863281, -82.756349);
Ecoregion region = getFirst(ecoregion);
assertThat(region.getName(), is("Trades - Caribbean Province"));
assertThat(region.getId(), is("LBP:CARB"));
assertThat(region.getPath(), is("Trades - Caribbean Province"));
}
use of com.vividsolutions.jts.geom.Point in project incubator-rya by apache.
the class GeoIndexerTest method testRestrictPredicatesSearch.
@Test
public void testRestrictPredicatesSearch() throws Exception {
conf.setStrings(ConfigUtils.GEO_PREDICATES_LIST, "pred:1,pred:2");
try (final GeoMesaGeoIndexer f = new GeoMesaGeoIndexer()) {
f.setConf(conf);
final ValueFactory vf = SimpleValueFactory.getInstance();
final Point point = gf.createPoint(new Coordinate(10, 10));
final Value pointValue = vf.createLiteral("Point(10 10)", GeoConstants.XMLSCHEMA_OGC_WKT);
final IRI invalidPredicate = GeoConstants.GEO_AS_WKT;
// These should not be stored because they are not in the predicate list
f.storeStatement(convertStatement(vf.createStatement(vf.createIRI("foo:subj1"), invalidPredicate, pointValue)));
f.storeStatement(convertStatement(vf.createStatement(vf.createIRI("foo:subj2"), invalidPredicate, pointValue)));
final IRI pred1 = vf.createIRI("pred:1");
final IRI pred2 = vf.createIRI("pred:2");
// These should be stored because they are in the predicate list
final Statement s3 = vf.createStatement(vf.createIRI("foo:subj3"), pred1, pointValue);
final Statement s4 = vf.createStatement(vf.createIRI("foo:subj4"), pred2, pointValue);
f.storeStatement(convertStatement(s3));
f.storeStatement(convertStatement(s4));
// This should not be stored because the object is not valid wkt
f.storeStatement(convertStatement(vf.createStatement(vf.createIRI("foo:subj5"), pred1, vf.createLiteral("soint(10 10)"))));
// This should not be stored because the object is not a literal
f.storeStatement(convertStatement(vf.createStatement(vf.createIRI("foo:subj6"), pred1, vf.createIRI("p:Point(10 10)"))));
f.flush();
final Set<Statement> actual = getSet(f.queryEquals(point, EMPTY_CONSTRAINTS));
Assert.assertEquals(2, actual.size());
Assert.assertTrue(actual.contains(s3));
Assert.assertTrue(actual.contains(s4));
}
}
use of com.vividsolutions.jts.geom.Point in project tests by datanucleus.
the class JtsGeometryMySQLTest method testMbrTouches.
public void testMbrTouches() throws SQLException, ParseException {
if (!runTestsForDatastore()) {
return;
}
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Point point = (Point) wktReader.read("POINT(75 75)");
Query query = pm.newQuery(SamplePolygon.class, "geom != null && MySQL.mbrTouches(:point, geom)");
List list = (List) query.execute(point);
assertEquals("Wrong number of geometries which are touched by a given point returned", 2, list.size());
assertTrue("Polygon 1 should be in the list of geometries which are touched by a given point", list.contains(getSamplePolygon(1)));
assertTrue("Polygon 2 should be in the list of geometries which are touched by a given point", list.contains(getSamplePolygon(2)));
} finally {
tx.commit();
}
}
use of com.vividsolutions.jts.geom.Point in project tests by datanucleus.
the class JtsGeometrySpatialTest method testGeomFromWKB.
public void testGeomFromWKB() throws SQLException, ParseException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Point geom = (Point) wktReader.read("POINT(10 10)");
Query query = pm.newQuery(SamplePoint.class, "geom != null && geom.equals(Spatial.geomFromWKB(Spatial.asBinary(:geom), Spatial.srid(:geom)))");
List list = (List) query.execute(geom);
assertEquals("Wrong number of geometries with a given wkb returned", 1, list.size());
assertTrue("Point 1 should be in the list of geometries with a given wkb", list.contains(getSamplePoint(1)));
} finally {
tx.commit();
}
}
use of com.vividsolutions.jts.geom.Point in project tests by datanucleus.
the class JtsGeometrySpatialTest method testPointFromWKB.
public void testPointFromWKB() throws SQLException, ParseException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Point geom = (Point) wktReader.read("POINT(75 75)");
Query query = pm.newQuery(SamplePoint.class, "geom != null && geom.equals(Spatial.pointFromWKB(Spatial.asBinary(:geom), Spatial.srid(:geom)))");
List list = (List) query.execute(geom);
assertEquals("Wrong number of geometries with a given wkb returned", 1, list.size());
assertTrue("Point 2 should be in the list of geometries with a given wkb", list.contains(getSamplePoint(2)));
} finally {
tx.commit();
}
}
Aggregations