use of com.vividsolutions.jts.geom.Coordinate in project UVMS-ActivityModule-APP by UnionVMS.
the class FluxMessageServiceBean method getGeometryFromSpatial.
/**
* Get Geometry information from spatial for FLUXLocation code
* @param fluxLocationIdentifier
* @return
*/
private Geometry getGeometryFromSpatial(String fluxLocationIdentifier) {
log.info("Get Geometry from Spatial for:" + fluxLocationIdentifier);
if (fluxLocationIdentifier == null) {
return null;
}
Geometry geometry = null;
try {
String geometryWkt = spatialModuleService.getGeometryForPortCode(fluxLocationIdentifier);
if (geometryWkt != null) {
Geometry value = GeometryMapper.INSTANCE.wktToGeometry(geometryWkt).getValue();
Coordinate[] coordinates = value.getCoordinates();
if (coordinates.length > 0) {
Coordinate coordinate = coordinates[0];
double x = coordinate.x;
double y = coordinate.y;
geometry = GeometryUtils.createPoint(x, y);
}
}
log.debug(" Geometry received from Spatial for:" + fluxLocationIdentifier + " :" + geometryWkt);
} catch (ServiceException | ParseException e) {
log.error("Exception while trying to get geometry from spatial", e);
}
return geometry;
}
use of com.vividsolutions.jts.geom.Coordinate in project activityinfo by bedatadriven.
the class BatchGeocoder method addPoint.
public void addPoint(double x, double y) {
int pointIndex = points.size();
// add the point to the list
points.add(gf.createPoint(new Coordinate(x, y)));
// index the point
index.add(new SweepLineInterval(x, x, pointIndex));
// add an empty result
results.add(new ArrayList<AdminEntity>());
}
use of com.vividsolutions.jts.geom.Coordinate in project activityinfo by bedatadriven.
the class Geocoder method geocode.
/**
* Geocode a single point to a list of admin entities
*
* @param latitude
* @param longitude
* @return
*/
public List<AdminEntity> geocode(double latitude, double longitude) {
Point point = gf.createPoint(new Coordinate(longitude, latitude));
Session session = sessionProvider.get();
Criteria criteria = session.createCriteria(AdminEntity.class);
criteria.add(SpatialRestrictions.contains("geometry", point));
// mysql seems to check only the MBRs. We need to verify
// that the point is actually contained by the geometry
List<AdminEntity> containedByMbr = criteria.list();
List<AdminEntity> contains = Lists.newArrayList();
for (AdminEntity entity : containedByMbr) {
if (JtsUtil.contains(entity.getGeometry(), point)) {
contains.add(entity);
}
}
return contains;
}
use of com.vividsolutions.jts.geom.Coordinate in project activityinfo by bedatadriven.
the class MySqlUpdateTest method updateGeometry.
@Test
public void updateGeometry() throws SQLException {
userId = 3;
ResourceId formId = CuidAdapter.adminLevelFormClass(1);
ResourceId recordId = entity(1);
ResourceId fieldId = CuidAdapter.field(formId, CuidAdapter.GEOMETRY_FIELD);
Optional<FormStorage> storage = catalog.getForm(formId);
GeometryFactory factory = new GeometryFactory();
Polygon polygon = new Polygon(new LinearRing(new CoordinateArraySequence(new Coordinate[] { new Coordinate(100, 0), new Coordinate(101, 0), new Coordinate(101, 1), new Coordinate(100, 1), new Coordinate(100, 0) }), factory), new LinearRing[0], factory);
storage.get().updateGeometry(recordId, fieldId, polygon);
query(formId, "_id", "ST_XMIN(boundary)", "ST_XMAX(boundary)");
}
use of com.vividsolutions.jts.geom.Coordinate in project sldeditor by robward-scisys.
the class ExampleLineImpl method getLine.
/*
* (non-Javadoc)
*
* @see com.sldeditor.datasource.impl.ExampleLineInterface#getLine()
*/
@Override
public LineString getLine() {
if (line == null) {
// CHECKSTYLE:OFF
double[][] rawLocations = new double[][] { { -123.167725, 48.502048 }, { -123.464355, 48.297812 }, { -124.738770, 48.603858 }, { -125.189209, 48.828566 }, { -125.112305, 48.951366 }, { -125.507812, 48.929718 }, { -125.870361, 49.145784 }, { -126.035156, 49.167339 }, { -126.112061, 49.253465 }, { -126.243896, 49.282140 }, { -126.287842, 49.360912 }, { -126.397705, 49.410973 }, { -126.573486, 49.375220 }, { -126.584473, 49.560852 }, { -126.815186, 49.610710 }, { -127.012939, 49.745781 }, { -126.947021, 49.788357 }, { -127.166748, 49.852152 }, { -127.518311, 50.113533 }, { -127.814941, 50.078295 }, { -127.957764, 50.120578 }, { -127.825928, 50.254230 }, { -128.012695, 50.331436 }, { -127.946777, 50.450509 }, { -128.122559, 50.457504 }, { -128.364258, 50.652943 }, { -128.342285, 50.792047 }, { -128.100586, 50.882243 }, { -127.858887, 50.944584 }, { -127.518311, 50.798991 }, { -127.221680, 50.639010 } };
// CHECKSTYLE:ON
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
Coordinate[] coords = new Coordinate[rawLocations.length];
int index = 0;
for (double[] point : rawLocations) {
Coordinate c = new Coordinate(point[0], point[1]);
coords[index] = c;
index++;
}
line = geometryFactory.createLineString(coords);
}
return line;
}
Aggregations