Search in sources :

Example 6 with Feature

use of ol.Feature in project gwt-ol3 by TDesjardins.

the class WktTest method createTestFeature.

private Feature createTestFeature() {
    Coordinate coordinate1 = new Coordinate(1, 1);
    Coordinate coordinate2 = new Coordinate(5, 5);
    Coordinate[] coordinates = { coordinate1, coordinate2 };
    LineString lineString = new LineString(coordinates);
    // Create feature
    FeatureOptions featureOptions = new FeatureOptions();
    featureOptions.setGeometry(lineString);
    return new Feature(featureOptions);
}
Also used : Coordinate(ol.Coordinate) LineString(ol.geom.LineString) Feature(ol.Feature) FeatureOptions(ol.FeatureOptions)

Example 7 with Feature

use of ol.Feature in project gwt-ol3 by TDesjardins.

the class WktTest method testWktToFeatures.

public void testWktToFeatures() {
    injectUrlAndTest(() -> {
        String wkt = wktFormat.writeFeatures(createTestFeatures(), null);
        assertNotNull(wkt);
        Feature[] features;
        features = wktFormat.readFeatures(wkt, null);
        assertNotNull(features);
        assertEquals(1, features.length);
        features = splittingWktFormat.readFeatures(wkt, null);
        assertNotNull(features);
        assertEquals(2, features.length);
    });
}
Also used : LineString(ol.geom.LineString) Feature(ol.Feature)

Example 8 with Feature

use of ol.Feature in project gwt-ol3 by TDesjardins.

the class WktTest method testWktToFeature.

public void testWktToFeature() {
    injectUrlAndTest(() -> {
        String wkt = wktFormat.writeFeature(createTestFeature(), null);
        assertNotNull(wkt);
        WktReadOptions readOptions = new WktReadOptions();
        assertNotNull(readOptions);
        Feature feature = wktFormat.readFeature(wkt, readOptions);
        assertNotNull(feature);
    });
}
Also used : LineString(ol.geom.LineString) Feature(ol.Feature)

Example 9 with Feature

use of ol.Feature in project gwt-ol3 by TDesjardins.

the class VectorTest method testVectorLayer.

@SuppressWarnings({ "static-method", "javadoc" })
public void testVectorLayer() {
    injectUrlAndTest(() -> {
        VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
        assertNotNull(vectorLayerOptions);
        Vector vectorLayer = new Vector(vectorLayerOptions);
        assertTrue(vectorLayer instanceof Base);
        assertTrue(vectorLayer instanceof Vector);
        vectorLayer.setStyle(new Style());
        assertTrue(vectorLayer.getStyle() instanceof Style);
        assertTrue(vectorLayer.getStyles() instanceof Style[]);
        Style[] styles = { new Style(), new Style() };
        vectorLayer.setStyles(styles);
        assertTrue(vectorLayer.getStyle() instanceof Style);
        assertTrue(vectorLayer.getStyles() instanceof Style[]);
        assertTrue(vectorLayer.getStyles().length == 2);
        vectorLayer.setStyleFunction((Feature feature) -> {
            return null;
        });
        assertTrue(vectorLayer.getStyle() == null);
        assertTrue(vectorLayer.getStyleFunction() instanceof GenericFunction);
    });
}
Also used : Style(ol.style.Style) GenericFunction(ol.GenericFunction) Feature(ol.Feature)

Example 10 with Feature

use of ol.Feature in project gwt-ol3 by TDesjardins.

the class GeoJsonTest method testGeoJsonToFeature.

public void testGeoJsonToFeature() {
    injectUrlAndTest(() -> {
        java.lang.Object geoJson = geoJsonFormat.writeFeatureObject(createTestFeature(), null);
        // Convert Features from GeoJSON
        Feature featureGeoJson = geoJsonFormat.readFeature(geoJson, null);
        assertNotNull(featureGeoJson);
    });
}
Also used : Feature(ol.Feature)

Aggregations

Feature (ol.Feature)12 LineString (ol.geom.LineString)7 Coordinate (ol.Coordinate)6 FeatureOptions (ol.FeatureOptions)6 Collection (ol.Collection)4 Map (ol.Map)4 MapOptions (ol.MapOptions)4 View (ol.View)4 ScaleLine (ol.control.ScaleLine)4 Base (ol.layer.Base)4 LayerOptions (ol.layer.LayerOptions)4 Tile (ol.layer.Tile)4 VectorLayerOptions (ol.layer.VectorLayerOptions)4 Osm (ol.source.Osm)4 Vector (ol.source.Vector)4 VectorOptions (ol.source.VectorOptions)4 XyzOptions (ol.source.XyzOptions)4 Rotate (ol.control.Rotate)3 KeyboardPan (ol.interaction.KeyboardPan)3 KeyboardZoom (ol.interaction.KeyboardZoom)3