use of com.vividsolutions.jts.geom.Coordinate in project ddf by codice.
the class TwitterFilterVisitor method visit.
/**
* DWithin filter maps to a Point/Radius distance Spatial search criteria.
*/
@Override
public Object visit(DWithin filter, Object data) {
LOGGER.trace("ENTERING: DWithin filter");
if (currentNest == null || NestedTypes.AND.equals(currentNest)) {
// The geometric point is wrapped in a <Literal> element, so have to
// get geometry expression as literal and then evaluate it to get
// the geometry.
// Example:
// <ogc:Literal>org.geotools.geometry.jts.spatialschema.geometry.primitive.PointImpl@dc33f184</ogc:Literal>
Literal literalWrapper = (Literal) filter.getExpression2();
// Luckily we know what type the geometry expression should be, so
// we
// can cast it
Point point = (Point) literalWrapper.evaluate(null);
Coordinate coords = point.getCentroid().getCoordinate();
double distance = filter.getDistance();
LOGGER.debug("point: coords[0] = {}, coords[1] = {}", coords.x, coords.y);
LOGGER.debug("radius = {}", distance);
longitude = coords.x;
latitude = coords.y;
radius = distance / 1000;
hasSpatial = true;
filters.add(filter);
} else {
LOGGER.warn(ONLY_AND_MSG);
}
LOGGER.trace("EXITING: DWithin filter");
return super.visit(filter, data);
}
use of com.vividsolutions.jts.geom.Coordinate in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testVisitBeyond.
@Test
public void testVisitBeyond() {
GeometryFactory geoFactory = new GeometryFactory();
double val = 30;
Expression pt1 = factory.literal(geoFactory.createPoint(new Coordinate(4, 5)));
Expression pt2 = factory.literal(geoFactory.createPoint(new Coordinate(6, 7)));
Beyond filter = factory.beyond(pt1, pt2, val, "kilometers");
Beyond duplicate = (Beyond) visitor.visit(filter, null);
assertThat(duplicate.getExpression1(), is(pt1));
assertThat(duplicate.getExpression2(), is(pt2));
assertThat(duplicate.getDistanceUnits(), is(UomOgcMapping.METRE.name()));
assertThat(duplicate.getDistance(), is(1000 * val));
}
use of com.vividsolutions.jts.geom.Coordinate in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testIntersectsUtm.
@Test
public void testIntersectsUtm() throws FactoryException, TransformException {
double lon = 33.45;
double lat = 25.22;
double easting = 545328.48;
double northing = 2789384.24;
CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:32636");
GeometryFactory geoFactory = new GeometryFactory();
Geometry utmPoint = geoFactory.createPoint(new Coordinate(easting, northing));
utmPoint.setUserData(sourceCRS);
Expression pt1 = factory.literal(geoFactory.createPoint(new Coordinate(1, 2)));
Expression pt2 = factory.literal(utmPoint);
Intersects filter = factory.intersects(pt1, pt2);
visitor.visit(filter, null);
assertThat(pt2, instanceOf(Literal.class));
Literal literalExpression = (Literal) pt2;
assertThat(literalExpression.getValue(), instanceOf(Geometry.class));
Geometry geometry = (Geometry) literalExpression.getValue();
assertThat(geometry.getCoordinates()[0].x, closeTo(lon, .00001));
assertThat(geometry.getCoordinates()[0].y, closeTo(lat, .00001));
}
use of com.vividsolutions.jts.geom.Coordinate in project ddf by codice.
the class TestGeoJsonExtensible method verifyBasics.
private void verifyBasics(Metacard metacard) throws ParseException {
assertEquals(DEFAULT_TITLE, metacard.getTitle());
assertEquals(DEFAULT_URI, metacard.getResourceURI().toString());
assertEquals(DEFAULT_TYPE, metacard.getContentTypeName());
assertEquals(DEFAULT_VERSION, metacard.getContentTypeVersion());
assertEquals("<xml></xml>", metacard.getMetadata());
SimpleDateFormat dateFormat = new SimpleDateFormat(GeoJsonInputTransformer.ISO_8601_DATE_FORMAT);
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
assertEquals(DEFAULT_CREATED_DATE, dateFormat.format(metacard.getCreatedDate()));
assertEquals(DEFAULT_MODIFIED_DATE, dateFormat.format(metacard.getModifiedDate()));
assertEquals(DEFAULT_EXPIRATION_DATE, dateFormat.format(metacard.getExpirationDate()));
assertEquals(DEFAULT_EFFECTIVE_DATE, dateFormat.format(metacard.getEffectiveDate()));
assertArrayEquals(DEFAULT_BYTES, metacard.getThumbnail());
assertEquals(DEFAULT_TEMPERATURE, metacard.getAttribute(TEMPERATURE_KEY).getValue());
assertEquals(BASIC_METACARD.getName(), metacard.getMetacardType().getName());
WKTReader reader = new WKTReader();
Geometry geometry = reader.read(metacard.getLocation());
Coordinate[] coords = geometry.getCoordinates();
assertThat(coords[0].x, is(30.0));
assertThat(coords[0].y, is(10.0));
assertThat(coords[1].x, is(10.0));
assertThat(coords[1].y, is(30.0));
assertThat(coords[2].x, is(40.0));
assertThat(coords[2].y, is(40.0));
}
use of com.vividsolutions.jts.geom.Coordinate in project ddf by codice.
the class WfsFilterDelegate method createPoint.
private JAXBElement<PointType> createPoint(String wkt) {
Coordinate[] coordinates = getCoordinatesFromWkt(wkt);
if (coordinates != null && coordinates.length > 0) {
StringBuilder coordString = new StringBuilder();
coordString.append(coordinates[0].x).append(",").append(coordinates[0].y);
CoordinatesType coordinatesType = new CoordinatesType();
coordinatesType.setValue(coordString.toString());
PointType point = new PointType();
point.setSrsName(srsName);
point.setCoordinates(coordinatesType);
return gmlObjectFactory.createPoint(point);
} else {
throw new IllegalArgumentException("Unable to parse Point coordinates from WKT String");
}
}
Aggregations