use of com.vividsolutions.jts.geom.Coordinate in project hibernate-orm by hibernate.
the class MySQLGeometryEquality method testVerticesEquality.
private boolean testVerticesEquality(Geometry geom1, Geometry geom2) {
if (geom1.getNumPoints() != geom2.getNumPoints()) {
return false;
}
for (int i = 0; i < geom1.getNumPoints(); i++) {
Coordinate cn1 = geom1.getCoordinates()[i];
Coordinate cn2 = geom2.getCoordinates()[i];
if (!cn1.equals2D(cn2)) {
return false;
}
}
return true;
}
use of com.vividsolutions.jts.geom.Coordinate in project elasticsearch by elastic.
the class GeoShapeQueryTests method testIndexPointsFilterRectangle.
public void testIndexPointsFilterRectangle() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("location").field("type", "geo_shape").field("tree", "quadtree").endObject().endObject().endObject().endObject().string();
client().admin().indices().prepareCreate("test").addMapping("type1", mapping, XContentType.JSON).execute().actionGet();
ensureGreen();
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject().field("name", "Document 1").startObject("location").field("type", "point").startArray("coordinates").value(-30).value(-30).endArray().endObject().endObject()).setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("test", "type1", "2").setSource(jsonBuilder().startObject().field("name", "Document 2").startObject("location").field("type", "point").startArray("coordinates").value(-45).value(-50).endArray().endObject().endObject()).setRefreshPolicy(IMMEDIATE).get();
ShapeBuilder shape = ShapeBuilders.newEnvelope(new Coordinate(-45, 45), new Coordinate(45, -45));
SearchResponse searchResponse = client().prepareSearch("test").setTypes("type1").setQuery(geoIntersectionQuery("location", shape)).execute().actionGet();
assertSearchResponse(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L));
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1"));
searchResponse = client().prepareSearch("test").setTypes("type1").setQuery(geoShapeQuery("location", shape)).execute().actionGet();
assertSearchResponse(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L));
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1"));
}
use of com.vividsolutions.jts.geom.Coordinate in project elasticsearch by elastic.
the class GeoShapeQueryTests method testEdgeCases.
public void testEdgeCases() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("location").field("type", "geo_shape").field("tree", "quadtree").endObject().endObject().endObject().endObject().string();
client().admin().indices().prepareCreate("test").addMapping("type1", mapping, XContentType.JSON).execute().actionGet();
ensureGreen();
client().prepareIndex("test", "type1", "blakely").setSource(jsonBuilder().startObject().field("name", "Blakely Island").startObject("location").field("type", "polygon").startArray("coordinates").startArray().startArray().value(-122.83).value(48.57).endArray().startArray().value(-122.77).value(48.56).endArray().startArray().value(-122.79).value(48.53).endArray().startArray().value(-122.83).value(48.57).endArray().endArray().endArray().endObject().endObject()).setRefreshPolicy(IMMEDIATE).get();
ShapeBuilder query = ShapeBuilders.newEnvelope(new Coordinate(-122.88, 48.62), new Coordinate(-122.82, 48.54));
// This search would fail if both geoshape indexing and geoshape filtering
// used the bottom-level optimization in SpatialPrefixTree#recursiveGetNodes.
SearchResponse searchResponse = client().prepareSearch("test").setTypes("type1").setQuery(geoIntersectionQuery("location", query)).execute().actionGet();
assertSearchResponse(searchResponse);
assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L));
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("blakely"));
}
use of com.vividsolutions.jts.geom.Coordinate in project series-rest-api by 52North.
the class HighchartFormatter method formatSeries.
private List<Number[]> formatSeries(QuantityData timeseries) {
List<Number[]> series = new ArrayList<>();
for (QuantityValue currentValue : timeseries.getValues()) {
List<Number> list = new ArrayList<>();
list.add(currentValue.getTimestamp());
list.add(currentValue.getValue());
if (currentValue.isSetGeometry()) {
Coordinate coordinate = currentValue.getGeometry().getCoordinate();
list.add(coordinate.x);
list.add(coordinate.y);
if (!Double.isNaN(coordinate.z)) {
list.add(coordinate.z);
}
}
series.add(list.toArray(new Number[0]));
}
return series;
}
use of com.vividsolutions.jts.geom.Coordinate in project series-rest-api by 52North.
the class FlotFormatter method formatSeries.
private List<Number[]> formatSeries(QuantityData timeseries) {
List<Number[]> series = new ArrayList<>();
for (QuantityValue currentValue : timeseries.getValues()) {
List<Number> list = new ArrayList<>();
list.add(currentValue.getTimestamp());
list.add(currentValue.getValue());
if (currentValue.isSetGeometry()) {
Coordinate coordinate = currentValue.getGeometry().getCoordinate();
list.add(coordinate.x);
list.add(coordinate.y);
if (!Double.isNaN(coordinate.z)) {
list.add(coordinate.z);
}
}
series.add(list.toArray(new Number[0]));
}
return series;
}
Aggregations