Search in sources :

Example 1 with Point

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);
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) JtsPoint(org.locationtech.spatial4j.shape.jts.JtsPoint) Point(com.vividsolutions.jts.geom.Point) JtsPoint(org.locationtech.spatial4j.shape.jts.JtsPoint) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder)

Example 2 with Point

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;
}
Also used : Point(com.vividsolutions.jts.geom.Point) GeojsonPoint(org.n52.io.geojson.old.GeojsonPoint) GeojsonPoint(org.n52.io.geojson.old.GeojsonPoint)

Example 3 with Point

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;
    }
}
Also used : BoundingBox(org.n52.io.crs.BoundingBox) CRSUtils(org.n52.io.crs.CRSUtils) Point(com.vividsolutions.jts.geom.Point) GeojsonPoint(org.n52.io.geojson.old.GeojsonPoint)

Example 4 with Point

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;
}
Also used : ValidationException(com.vaadin.data.ValidationException) Point(com.vividsolutions.jts.geom.Point) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Binder(com.vaadin.data.Binder) Button(com.vaadin.ui.Button) TabSheet(com.vaadin.ui.TabSheet) CheckBox(com.vaadin.ui.CheckBox) VerticalLayout(com.vaadin.ui.VerticalLayout) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 5 with Point

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;
}
Also used : Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) VerticalLayout(com.vaadin.ui.VerticalLayout) Point(com.vividsolutions.jts.geom.Point) PointField(org.vaadin.addon.leaflet.util.PointField) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

Point (com.vividsolutions.jts.geom.Point)142 Coordinate (com.vividsolutions.jts.geom.Coordinate)50 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)47 Geometry (com.vividsolutions.jts.geom.Geometry)45 LineString (com.vividsolutions.jts.geom.LineString)29 Polygon (com.vividsolutions.jts.geom.Polygon)26 ArrayList (java.util.ArrayList)25 List (java.util.List)22 SamplePoint (org.datanucleus.samples.jtsgeometry.SamplePoint)22 PersistenceManager (javax.jdo.PersistenceManager)18 Transaction (javax.jdo.Transaction)18 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)17 Query (javax.jdo.Query)17 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)15 GeometryCollection (com.vividsolutions.jts.geom.GeometryCollection)14 Test (org.junit.Test)14 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)11 DefaultGeometryProperty (eu.esdihumboldt.hale.common.instance.geometry.DefaultGeometryProperty)10 CRSDefinition (eu.esdihumboldt.hale.common.schema.geometry.CRSDefinition)9 SimpleFeature (org.opengis.feature.simple.SimpleFeature)7