use of com.vividsolutions.jts.geom.Point in project elasticsearch by elastic.
the class GeoJSONShapeParserTests method testThatParserExtractsCorrectTypeAndCoordinatesFromArbitraryJson.
public void testThatParserExtractsCorrectTypeAndCoordinatesFromArbitraryJson() throws IOException {
XContentBuilder pointGeoJson = XContentFactory.jsonBuilder().startObject().startObject("crs").field("type", "name").startObject("properties").field("name", "urn:ogc:def:crs:OGC:1.3:CRS84").endObject().endObject().field("bbox", "foobar").field("type", "point").field("bubu", "foobar").startArray("coordinates").value(100.0).value(0.0).endArray().startObject("nested").startArray("coordinates").value(200.0).value(0.0).endArray().endObject().startObject("lala").field("type", "NotAPoint").endObject().endObject();
Point expected = GEOMETRY_FACTORY.createPoint(new Coordinate(100.0, 0.0));
assertGeometryEquals(new JtsPoint(expected, SPATIAL_CONTEXT), pointGeoJson);
}
use of com.vividsolutions.jts.geom.Point in project series-rest-api by 52North.
the class CRSUtils method convertToGeojsonFrom.
/**
* Creates a GeoJSON representation of the given point. Adds a named <code>crs</code> member if
* it is different to the internally used CRS:84.
*
* @param point the point to be converted to GeoJSON.
* @param targetCrs the target CRS.
* @return a GeoJSON representation of the given point.
* @throws TransformException if transforming point fails.
* @throws FactoryException if creating the target CRS fails.
*/
public GeojsonPoint convertToGeojsonFrom(Point point, String targetCrs) throws TransformException, FactoryException {
Point transformedPoint = (Point) transformInnerToOuter(point, targetCrs);
GeojsonPoint asGeoJSON = convertToGeojsonFrom(transformedPoint);
if (!DEFAULT_CRS.equalsIgnoreCase(targetCrs)) {
asGeoJSON.setCrs(GeojsonCrs.createNamedCRS(targetCrs));
}
return asGeoJSON;
}
use of com.vividsolutions.jts.geom.Point in project series-rest-api by 52North.
the class IoParameters method mergeBounds.
private BoundingBox mergeBounds(BoundingBox bounds, BBox bboxBounds) {
if (bboxBounds == null) {
// nothing to merge
return bounds;
}
CRSUtils crsUtils = CRSUtils.createEpsgForcedXYAxisOrder();
Point lowerLeft = crsUtils.convertToPointFrom(bboxBounds.getLl());
Point upperRight = crsUtils.convertToPointFrom(bboxBounds.getUr());
if (bounds == null) {
BoundingBox parsed = new BoundingBox(lowerLeft, upperRight, CRSUtils.DEFAULT_CRS);
LOGGER.debug("Parsed bbox bounds: {}", parsed.toString());
return parsed;
} else {
extendBy(lowerLeft, bounds);
extendBy(upperRight, bounds);
LOGGER.debug("Merged bounds: {}", bounds.toString());
return bounds;
}
}
use of com.vividsolutions.jts.geom.Point in project v-leaflet by mstahv.
the class JtsPointFieldTest method getTestComponent.
// private Polygon polygon;
@Override
public Component getTestComponent() {
content.setMargin(true);
display.setContentMode(ContentMode.PREFORMATTED);
display.setCaption("Pojo state:");
display.setValue(pojo.toString());
HorizontalLayout horizontalLayout = new HorizontalLayout();
horizontalLayout.setSizeFull();
VerticalLayout editorform = new VerticalLayout();
editorform.setSizeFull();
editorform.setSpacing(true);
editorform.setCaption("Edit JTS pojo:");
TabSheet jtsFields = new TabSheet(point);
jtsFields.setCaption("JTS fiels:");
jtsFields.setSizeFull();
editorform.addComponents(new HorizontalLayout(name, date), jtsFields);
editorform.setExpandRatio(jtsFields, 1);
final Binder<JtsPojo> beanBinder = new Binder<>(JtsPojo.class);
beanBinder.readBean(pojo);
beanBinder.bindInstanceFields(this);
HorizontalLayout buttonLayout = new HorizontalLayout();
buttonLayout.addComponent(new Button("Save", (ClickListener) event -> {
try {
beanBinder.writeBean(pojo);
display.setValue(pojo.toString());
} catch (ValidationException e) {
System.err.println("Validation errors:" + Arrays.toString(e.getBeanValidationErrors().toArray()));
}
}));
CheckBox roCheckBox = new CheckBox("Read only", false);
roCheckBox.addValueChangeListener(event -> beanBinder.setReadOnly(event.getValue()));
buttonLayout.addComponent(roCheckBox);
buttonLayout.addComponent(new Button("Assign new empty bean", (ClickListener) event -> {
pojo = new JtsPojo();
beanBinder.readBean(pojo);
display.setValue(pojo.toString());
}));
buttonLayout.addComponent(new Button("Assign bean with preset data", (ClickListener) event -> {
pojo = new JtsPojo();
pojo.setPoint(JTSUtil.toPoint(new org.vaadin.addon.leaflet.shared.Point(61, 22)));
beanBinder.readBean(pojo);
display.setValue(pojo.toString());
}));
editorform.addComponent(buttonLayout);
horizontalLayout.addComponents(editorform, display);
horizontalLayout.setExpandRatio(editorform, 1);
horizontalLayout.setExpandRatio(display, 1);
return horizontalLayout;
}
use of com.vividsolutions.jts.geom.Point in project v-leaflet by mstahv.
the class WithoutBeanBindingTest method getTestComponent.
@Override
public Component getTestComponent() {
final PointField pointFieldEmpty = new PointField("empty PointField");
pointFieldEmpty.setSizeFull();
final PointField pointFieldInitialized = new PointField("PointField with value");
pointFieldInitialized.setSizeFull();
pointFieldInitialized.getMap().setZoomLevel(8);
pointFieldInitialized.setValue(getPoint());
Button getValueButton = new Button("Get values");
getValueButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
Point value1 = pointFieldEmpty.getValue();
Point value2 = pointFieldInitialized.getValue();
Notification.show(value1 + "\n" + value2);
}
});
HorizontalLayout fieldLayout = new HorizontalLayout(pointFieldEmpty, pointFieldInitialized);
fieldLayout.setSizeFull();
fieldLayout.setSpacing(true);
VerticalLayout layout = new VerticalLayout(fieldLayout, getValueButton);
layout.setExpandRatio(fieldLayout, 1f);
layout.setSizeFull();
layout.setSpacing(true);
return layout;
}
Aggregations