Search in sources :

Example 1 with Point

use of org.gwtopenmaps.openlayers.client.geometry.Point in project kapua by eclipse.

the class DevicesMap method placeMarkers.

private void placeMarkers(List<GwtDevice> devices) {
    LonLat lonLat = null;
    final List<GwtDevice> theDevices = devices;
    for (int i = 0; i < devices.size(); i++) {
        final GwtDevice theDevice = devices.get(i);
        if (theDevice.getGpsLatitude() != null && theDevice.getGpsLongitude() != null) {
            StringBuilder sbDeviceTitle = new StringBuilder();
            if (theDevice.getDisplayName() != null) {
                sbDeviceTitle.append(theDevice.getDisplayName()).append(" (").append(theDevice.getClientId()).append(")");
            } else {
                sbDeviceTitle.append(theDevice.getClientId());
            }
            lonLat = new LonLat(theDevice.getGpsLongitude(), theDevice.getGpsLatitude());
            lonLat.transform(DEFAULT_PROJECTION.getProjectionCode(), m_map.getProjection());
            // lets create a vector point on the location
            Style pointStyle = new Style();
            pointStyle.setFillOpacity(0.9);
            pointStyle.setExternalGraphic("eclipse/org/eclipse/kapua/app/console/icon/device_map.png");
            pointStyle.setGraphicSize(37, 34);
            pointStyle.setGraphicOffset(-10, -34);
            pointStyle.setGraphicName(theDevice.getDisplayName());
            Point point = new Point(theDevice.getGpsLongitude(), theDevice.getGpsLatitude());
            // transform point to OSM coordinate system
            point.transform(DEFAULT_PROJECTION, new Projection(m_map.getProjection()));
            VectorFeature pointFeature = new VectorFeature(point, pointStyle);
            Attributes attributes = new Attributes();
            attributes.setAttribute("deviceIdx", i);
            pointFeature.setAttributes(attributes);
            m_markerLayer.addFeature(pointFeature);
        }
    }
    // Click SelectFeature and its Options
    SelectFeatureOptions clickFeatureOptions = new SelectFeatureOptions();
    clickFeatureOptions.onSelect(new SelectFeatureListener() {

        @Override
        public void onFeatureSelected(VectorFeature theVectorFeature) {
            int deviceIdx = theVectorFeature.getAttributes().getAttributeAsInt("deviceIdx");
            GwtDevice device = theDevices.get(deviceIdx);
            if (device != null) {
                m_devicesView.setDevice(device);
            }
        }
    });
    SelectFeature clickFeature = new SelectFeature(m_markerLayer, clickFeatureOptions);
    clickFeature.setClickOut(true);
    clickFeature.setMultiple(false);
    // Hover SelectFeature and its Options
    SelectFeatureOptions hoverFeatureOptions = new SelectFeatureOptions();
    hoverFeatureOptions.setHover();
    hoverFeatureOptions.setHighlightOnly(true);
    hoverFeatureOptions.setRenderIntent(RenderIntent.DEFAULT);
    final SelectFeature hoverFeature = new SelectFeature(m_markerLayer, hoverFeatureOptions);
    hoverFeature.setClickOut(true);
    hoverFeature.setMultiple(false);
    hoverFeature.addFeatureHighlightedListener(new FeatureHighlightedListener() {

        @Override
        public void onFeatureHighlighted(VectorFeature theVectorFeature) {
            int deviceIdx = theVectorFeature.getAttributes().getAttributeAsInt("deviceIdx");
            GwtDevice device = theDevices.get(deviceIdx);
            if (device != null) {
                if (m_popup != null) {
                    m_map.removePopup(m_popup);
                }
                LonLat lonLat = theVectorFeature.getCenterLonLat();
                m_popup = new AnchoredBubble("marker-info", lonLat, new Size(185, 20), "<p>" + device.getDisplayName() + " (" + device.getClientId() + ")</p>", null, false);
                m_map.addPopup(m_popup);
            }
        }
    });
    hoverFeature.addFeatureUnhighlightedListener(new FeatureUnhighlightedListener() {

        @Override
        public void onFeatureUnhighlighted(VectorFeature eventObject) {
            if (m_popup != null) {
                m_map.removePopup(m_popup);
                m_popup = null;
            }
            hoverFeature.unselectAll(null);
        }
    });
    m_map.addControl(clickFeature);
    m_map.addControl(hoverFeature);
    hoverFeature.activate();
    clickFeature.activate();
    // auto-adjust the zoom to show all points
    if (m_markerLayer.getDataExtent() != null) {
        m_map.zoomToExtent(m_markerLayer.getDataExtent());
    } else {
        m_map.zoomTo(1);
    }
}
Also used : FeatureHighlightedListener(org.gwtopenmaps.openlayers.client.event.FeatureHighlightedListener) Size(org.gwtopenmaps.openlayers.client.Size) Attributes(org.gwtopenmaps.openlayers.client.util.Attributes) Projection(org.gwtopenmaps.openlayers.client.Projection) LonLat(org.gwtopenmaps.openlayers.client.LonLat) Point(org.gwtopenmaps.openlayers.client.geometry.Point) Point(org.gwtopenmaps.openlayers.client.geometry.Point) AnchoredBubble(org.gwtopenmaps.openlayers.client.popup.AnchoredBubble) SelectFeatureListener(org.gwtopenmaps.openlayers.client.control.SelectFeature.SelectFeatureListener) GwtDevice(org.eclipse.kapua.app.console.shared.model.GwtDevice) VectorFeature(org.gwtopenmaps.openlayers.client.feature.VectorFeature) Style(org.gwtopenmaps.openlayers.client.Style) SelectFeatureOptions(org.gwtopenmaps.openlayers.client.control.SelectFeatureOptions) SelectFeature(org.gwtopenmaps.openlayers.client.control.SelectFeature) FeatureUnhighlightedListener(org.gwtopenmaps.openlayers.client.event.FeatureUnhighlightedListener)

Example 2 with Point

use of org.gwtopenmaps.openlayers.client.geometry.Point in project geo-platform by geosdi.

the class WktPointGeometryBuilder method buildWktMultiGeometry.

@Override
protected final String buildWktMultiGeometry(VectorFeature feature) {
    Point point = Point.narrowToPoint(feature.getGeometry().getJSObject());
    MultiPoint multiPoint = new MultiPoint(new Point[] { point });
    return multiPoint.toString();
}
Also used : MultiPoint(org.gwtopenmaps.openlayers.client.geometry.MultiPoint) Point(org.gwtopenmaps.openlayers.client.geometry.Point) MultiPoint(org.gwtopenmaps.openlayers.client.geometry.MultiPoint)

Example 3 with Point

use of org.gwtopenmaps.openlayers.client.geometry.Point in project geo-platform by geosdi.

the class GPRoutingEndPoint method drawFeature.

/**
 * (non-Javadoc)
 *
 * @see
 * org.geosdi.geoplatform.gui.puregwt.routing.event.FinalRoutingPointEventHandler#drawFeature(org.geosdi.geoplatform.gui.model.IGeoPlatformLocation)
 */
@Override
public void drawFeature(IGeoPlatformLocation location) {
    LonLat ll = new LonLat(location.getLon(), location.getLat());
    if (geoPlatformMap.getMap().getProjection().equals(GPCoordinateReferenceSystem.GOOGLE_MERCATOR.getCode())) {
        ll.transform(GPCoordinateReferenceSystem.WGS_84.getCode(), GPCoordinateReferenceSystem.EPSG_GOOGLE.getCode());
    }
    if (!this.boxesWidget.containsLonLat(ll)) {
        GeoPlatformMessage.errorMessage(BasicWidgetConstants.INSTANCE.GPRoutingEndPoint_errorMessageTitleText(), BasicWidgetConstants.INSTANCE.GPRoutingEndPoint_errorMessageBodyText());
        return;
    }
    if (feature != null) {
        layer.removeFeature(feature);
    }
    Point p = new Point(ll.lon(), ll.lat());
    feature = new VectorFeature(p);
    feature.setStyle(style);
    layer.addFeature(feature);
}
Also used : VectorFeature(org.gwtopenmaps.openlayers.client.feature.VectorFeature) LonLat(org.gwtopenmaps.openlayers.client.LonLat) Point(org.gwtopenmaps.openlayers.client.geometry.Point)

Example 4 with Point

use of org.gwtopenmaps.openlayers.client.geometry.Point in project geo-platform by geosdi.

the class GPRoutingStartPoint method drawFeature.

/**
 * (non-Javadoc)
 *
 * @see
 * org.geosdi.geoplatform.gui.puregwt.routing.event.StartRoutingPointEventHandler#drawFeature(org.geosdi.geoplatform.gui.model.IGeoPlatformLocation)
 */
@Override
public void drawFeature(IGeoPlatformLocation location) {
    LonLat ll = new LonLat(location.getLon(), location.getLat());
    if (geoPlatformMap.getMap().getProjection().equals(GPCoordinateReferenceSystem.GOOGLE_MERCATOR.getCode())) {
        ll.transform(GPCoordinateReferenceSystem.WGS_84.getCode(), GPCoordinateReferenceSystem.EPSG_GOOGLE.getCode());
    }
    if (!this.boxesWidget.containsLonLat(ll)) {
        GeoPlatformMessage.errorMessage(BasicWidgetConstants.INSTANCE.GPRoutingStartPoint_errorMessageTitleText(), BasicWidgetConstants.INSTANCE.GPRoutingStartPoint_errorMessageBodyText());
        return;
    }
    if (feature != null) {
        layer.removeFeature(feature);
    }
    Point p = new Point(ll.lon(), ll.lat());
    feature = new VectorFeature(p);
    feature.setStyle(style);
    layer.addFeature(feature);
}
Also used : VectorFeature(org.gwtopenmaps.openlayers.client.feature.VectorFeature) LonLat(org.gwtopenmaps.openlayers.client.LonLat) Point(org.gwtopenmaps.openlayers.client.geometry.Point)

Example 5 with Point

use of org.gwtopenmaps.openlayers.client.geometry.Point in project geo-platform by geosdi.

the class PointEditorHandler method checkModifications.

@Override
protected boolean checkModifications(VectorFeature feature) {
    Point oldPoint = Point.narrowToPoint(modifyEditorControl.getSelectedFeature().getGeometry().getJSObject());
    Point po = Point.narrowToPoint(feature.getGeometry().getJSObject());
    return ((po.getX() == oldPoint.getX()) && (po.getY() == oldPoint.getY()));
}
Also used : Point(org.gwtopenmaps.openlayers.client.geometry.Point)

Aggregations

Point (org.gwtopenmaps.openlayers.client.geometry.Point)9 VectorFeature (org.gwtopenmaps.openlayers.client.feature.VectorFeature)4 LonLat (org.gwtopenmaps.openlayers.client.LonLat)3 Projection (org.gwtopenmaps.openlayers.client.Projection)2 GwtDevice (org.eclipse.kapua.app.console.shared.model.GwtDevice)1 Size (org.gwtopenmaps.openlayers.client.Size)1 Style (org.gwtopenmaps.openlayers.client.Style)1 SelectFeature (org.gwtopenmaps.openlayers.client.control.SelectFeature)1 SelectFeatureListener (org.gwtopenmaps.openlayers.client.control.SelectFeature.SelectFeatureListener)1 SelectFeatureOptions (org.gwtopenmaps.openlayers.client.control.SelectFeatureOptions)1 FeatureHighlightedListener (org.gwtopenmaps.openlayers.client.event.FeatureHighlightedListener)1 FeatureUnhighlightedListener (org.gwtopenmaps.openlayers.client.event.FeatureUnhighlightedListener)1 MultiPoint (org.gwtopenmaps.openlayers.client.geometry.MultiPoint)1 Vector (org.gwtopenmaps.openlayers.client.layer.Vector)1 AnchoredBubble (org.gwtopenmaps.openlayers.client.popup.AnchoredBubble)1 Attributes (org.gwtopenmaps.openlayers.client.util.Attributes)1