Git Product home page Git Product logo

leaflet-wfst's Introduction

Leaflet-WFST

Build Status

OGC WFS-T client layer for leaflet.

Install plugin

Via npm:

  npm i leaflet-wfst --save

Via Bower:

  bower i leaflet-wfst --save

From GitHub:

  npm i -S git://github.com/Flexberry/Leaflet-WFST.git#v1.1.1

where #v1.1.1 is version of specific release.

Initialization options

   options: {
        crs: L.CRS.EPSG3857,
        showExisting: true,
        geometryField: 'Shape',
        url: '',
        typeNS: '',
        typeName: '',
        opacity: 1,
        style: {
            color: 'black',
            weight: 1
        }
    }

Example

const wfstPointOptions = {
  crs: L.CRS.EPSG4326,
  showExisting: true,
  geometryField: 'geom',
  url: `http://localhost:8080/geoserver/wfs`,
  typeNS: 'test',
  typeName: 'test',
  maxFeatures: 90,
  opacity: 1,
  style: function(layer) {
    // you can use if statemt etc
    return {
      color: 'black',
      weight: 1
    }
  },
};
const wfstPoint = new L.WFST(wfstPointOptions, new L.Format.GeoJSON({
  crs: L.CRS.EPSG4326,
  pointToLayer(geoJsonPoint, latlng) {
    const layer = new L.CircleMarker(latlng, {
      radius: 10,
    });
    return layer;
  },
}));
wfstPoint.addTo(map);
option name default comment
crs L.CRS.EPSG3857 spatial reference system for layer, should implement ICRS, for example Proj4Leaflet
showExisting true load existing features on create layer
geometryField 'Shape' field for storing geometries, for non transaction services may be ommited
url - WFS url, for example http://demo.opengeo.org/geoserver/osm/ows
typeNS - type namespace
typeName - type name
typeNSName - type namespace name
namespaceUri - namespace URI
opacity 1 layer's opacity
style - leaflet vector style. function or object
filter - any filter. see filter
maxFeatures - limit the amount of features returned

Basic WFS example - view

var map = L.map('map').setView([0, 0], 2);

var boundaries = new L.WFS({
    url: 'http://demo.opengeo.org/geoserver/ows',
    typeNS: 'topp',
    typeName: 'tasmania_state_boundaries',
    crs: L.CRS.EPSG4326,
    style: {
        color: 'blue',
        weight: 2
    }
}).addTo(map)
  .on('load', function () {
      map.fitBounds(boundaries);
  })

Methods

Extends leaflet classes with toGml(crs) function:

  • L.Marker
  • L.Polygon
  • L.Polyline
  • L.MultiPolygon
  • L.MultiPolyline
  • L.LatLngBounds

Events

Triggers two type of events:

  • load - triggers when both 'DescribeFeatureType' & 'GetFeature' requests succeed, and features have been successfully parsed into leaflet layers
  • error - triggers when any 'DescribeFeatureType' or 'GetFeature' request fails, and features haven't been parsed into leaflet layers

Markers geometry writes as posNode, for all other layers geometry writes as posList

Filter

Realization of OGC Filter Encoding v1.1.0

Filter implementations return only inner content of filter element.

Some considerations for all filter constructors:

  • "expression" - propertyName, literal, operator filter or function
  • "propertyExpression" - if argument on this position is not Element and is not "expression" method it suspect to be a propertyName
  • "literalExpression" - if argument on this position is not Element and is not "expression" it suspect to be a literal
Name Constructor
ID
GmlObjectId L.Filter.GmlObjectId(value id)
Comparisons
PropertyIsEqualTo L.Filter.EQ(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase)
PropertyIsNotEqualTo L.Filter.NotEQ(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase)
PropertyIsLessThan L.Filter.LT(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase)
PropertyIsGreaterThan L.Filter.GT(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase)
PropertyIsLessThanOrEqualTo L.Filter.LEQ(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase)
PropertyIsGreaterThanOrEqualTo L.Filter.GEQ(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase)
PropertyIsLike L.Filter.Like(string propertyName,string likeExpression,object attributes)
PropertyIsNull L.Filter.IsNull(string propertyName)
PropertyIsBetween L.Filter.IsBetween(propertyExpression firstArgument, literalExpression lowerBoundary, literalExpression upperBoundary)
Operators
Add L.Filter.Add(expression, expression)
Sub L.Filter.Sub(expression, expression)
Mul L.Filter.Mul(expression, expression)
Div L.Filter.Div(expression, expression)
Logic
And L.Filter.And(expression[, expression]*)
Or L.Filter.Or(expression[, expression]*)
Not L.Filter.Not(expression)
Spatial
BBox L.Filter.BBox(string propertyName, latLngBounds bounds, ICRS crs)
Equals L.Filter.Equals(string propertyName, Layer geometry, ICRS crs)
Disjoint L.Filter.Disjoint(string propertyName, Layer geometry, ICRS crs)
Touches L.Filter.Touches(string propertyName, Layer geometry, ICRS crs)
Within L.Filter.Within(string propertyName, Layer geometry, ICRS crs)
Overlaps L.Filter.Overlaps(string propertyName, Layer geometry, ICRS crs)
Crosses L.Filter.Crosses(string propertyName, Layer geometry, ICRS crs)
Intersects L.Filter.Intersects(string propertyName, Layer geometry, ICRS crs)
Contains L.Filter.Contains(string propertyName, Layer geometry, ICRS crs)
Spatial distance buffer
DWithin L.Filter.DWithin(string propertyName, Layer geometry, ICRS crs, value distance, string units)
Beyond L.Filter.Beyond(string propertyName, Layer geometry, ICRS crs, value distance, string units)
Other
Function L.Filter.Function(string functionName[, expression]*)
PropertyName L.Filter.propertyName(string name)
Literal L.Filter.literal(value)

PropertyName and Literal is functions and returns Gml directly.

Examples

FeatureID

In standard there are two filters - GmlObjectID and FeatureID, but latest is marked as deprecated and so is not implemented.

Example:

  var filter = new L.Filter.GmlObjectID(1);  

result xml:

  <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
    <ogc:GmlObjectId xmlns:gml="http://www.opengis.net/gml" gml:id="1" />
  </ogc:Filter>

PropertyIsEqualTo

  var filter = new L.Filter.EQ('city', 'Perm');
  filter.toGml()

result xml:

  <ogc:PropertyIsEqualTo>
    <ogc:PropertyName>city</ogc:PropertyName>
    <ogc:Literal>Perm</ogc:Literal>
  </ogc:PropertyIsEqualTo>

PropertyIsLike

This filter accept optional attributes object:

 attributes: {
    wildCard: '*',
    singleChar: '#',
    escapeChar: '!',
    matchCase: true
  }
  var filter = new L.Filter.Like('city', '*perm*', { matchCase: false });
  filter.toGml()

result xml:

  <ogc:ogc:PropertyIsLike wildCard="*" singleChar="#" escapeChar="!" matchCase="false">
    <ogc:PropertyName>city</ogc:PropertyName>
    <ogc:Literal>*perm*</ogc:Literal>
  </ogc:ogc:PropertyIsLike>

BBox

Example:

    var filter = new L.Filter.BBox('ogr_geometry', L.latLngBounds(L.latLng(40.712, -74.227), L.latLng(40.774, -74.125)), L.CRS.EPSG4326);
    filter.toGml()

result xml:

  <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
    <ogc:BBOX>
      <ogc:PropertyName>ogr_geometry</ogc:PropertyName>
      <gml:Envelope xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
        <gml:lowerCorner>-74.227 40.712</gml:lowerCorner>
        <gml:upperCorner>-74.125 40.774</gml:upperCorner>
      </gml:Envelope>
    </ogc:BBOX>
  </ogc:Filter>

Intersects

Example:

  var filter = new L.Filter.Intersects('ogr_geometry', L.polygon([L.latLng(40.712, -74.227), L.latLng(40.774, -74.125), L.latLng(40.734, -74.175)]), L.CRS.EPSG4326);
  filter.toGml();

result xml:

  <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
    <ogc:Intersects>
      <ogc:PropertyName>ogr_geometry</ogc:PropertyName>
      <gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326" srsDimension="2">
        <gml:exterior>
          <gml:LinearRing srsDimension="2">
            <gml:posList>-74.227 40.712 -74.125 40.774 -74.175 40.734 -74.227 40.712</gml:posList>
          </gml:LinearRing>
        </gml:exterior>
      </gml:Polygon>
    </ogc:Intersects>
  </ogc:Filter>

WFST Example

Editing plugin - Leaflet.Editable

L.WFST.include(MultiEditableMixin);

var wfst = new L.WFST({
    url: 'http://myserver/geoserver/ows',
    typeNS: 'myns',
    typeName: 'POIPOINT',
    style: {
        color: 'blue',
        weight: 2
    }
}).addTo(map).once('load', function () {
            map.fitBounds(wfst);
            wfst.enableEdit();
        });

map.on('editable:created', function (e) {
    wfst.addLayer(e.layer);
});

map.on('editable:editing', function (e) {
    wfst.editLayer(e.layer);
});

to make "wfs:Transaction" POST request call save() method, example with Leaflet.EasyButton

 L.easyButton('fa-save', function () {
     wfst.save();
 }, 'Save changes');

Layer properties

//simple layer
layer = new L.Marker([0, 0]);
layer.feature = {
  id: 1,
  properties: {
    a: 'a',
    b: 'b'
  }
};

//get value by key 'a'
var a = layer.getProperty('a');

//change values
layer.setProperties({
  a: 'b',
  b:'a'
});

//add new property
layer.setProperties({
  c:'c'
});

//delete properties
layer.deleteProperties(['a','b','c']);

Demo

demos for GML read format

demo for GeoJSON read format

demo filter bbox

License

MIT License

leaflet-wfst's People

Contributors

almostcake avatar arszp10 avatar bratchikov avatar dashayulbarisova avatar dubrovinpavel avatar ehaberev avatar kuzkok avatar seregamatin avatar wouldgo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leaflet-wfst's Issues

Internet Explorer doesn't support XPathEvaluator

Great extension, but unfortunately I'm having problems with some users who want to use IE(?!).

var xpe = new XPathEvaluator();

This seems to be causing issues when trying to use in Internet Explorer (I tested using IE10).

From some Googling:

Internet Explorer is the only browser that now doesn't support XPathEvaluator. You can use selectNode() and selectSingleNode() on the DOM Document object instead (IE only).

Does Leaflet-WFST-Layer store Attributes?

During a study project I created a WFS-T service unsing Geoserver and a PostGIS Database (for storing the data). Now I would like to create a Leaflet application that allows users to edit the features of the WFST. Not only the geometry should be editable, also the attributes of the features.
To edit the attributes I found the part "Layer properties" in the documentation. So my first step was to create a popup showing some text, when a feature in the map is clicked. The result was what I expected. So in the next step i tried to replace the text in the popup with a number from the attributefield 'Count' using the method "getProperty('Count'). After that change I got an errormessage saying "Uncaught TypeError: cannot read property 'getProperty' of undefined". I interpreted this message as: Attributes are not saved in the layer so the method can't get an attribute with the fieldname 'Count' because it is not defined.
So my question is: Are the attributes not saved automatically if I create a new WFST-Layer? And if they are, how is it possible to get the attributes?

Here is an minimalistic version of my used sourcecode:

...
  <div id="mapid" style="width: 800px; height: 800px;"></div>

  <script>

      //creating map
      var mymap = L.map('mapid').setView([51.14, 8.01], 11);

      //adding WFST-Layer
      var testWFST = new L.WFST({
                url: 'http://localhost:8080/geoserver/TEST/ows?',
                typeNS: 'TEST',
                typeName: 'Testshape',
                style: {
                     color: 'blue',
                     weight: 2
                },
                geometryField: 'geometrie'
              }).addTo(mymap).once('load', function(){
                mymap.fitBounds(testWFST);
                testWFST.enableEdit();
              });

      //open Popup with attributes, when map is clicked
      mymap.on('click', function(e){
                mymap.openPopup(e.layer.getProperty('Anzahl'));	//Errormessage referencing to this line
          });
      </script>

BindPopup to Layer

Hi there

Thanks for the plugin. I've been testing it out and it works great.

I'm finding it difficult to add a popup to the layer using. Is this possible with the plugin.

Here is the code for my layer

var boundary = new L.WFS({
url: 'http://10.0.1.218/geoserver/nd_test/ows',
typeName: 'Boundary_region',
crs: L.CRS.EPSG4326,
geometryField:'geom'
},new L.Format.GeoJSON({crs: L.CRS.EPSG4326})
).addTo(map)
.on('load', function () {
map.fitBounds(boundary);    
});

WFS data by mapExtent

Hello.
Thanks for plugin, but i have one issue.
I have weight data on my geoserver, and i don't want to load it all at once, but specified by map extent. Is it possible with your plugin? I tried to do it on my own with ajax sending request to wfs with parameter bbox on mapmove event, but it downloaded huge response data on every map move. Maybe your plugin can handle this easily?

Mat.

Problems importing WFS with Leaflet 0.7.7

I am having problems getting WFS layers to appear on my map. I am using Leaflet version 0.7.7
and I am using layers from:

http://demo.opengeo.org/geoserver/wfs

I have tried just about every layer they support.

I get a plethora of different errors:

TypeError: hole is undefined
{domain}/assets/leaflet.self-45659c657e1c7526f5ad36ed2ca57f9d2689bfcb5c96bc84e276d8b9a9e477b0.js?body=1
Line 5669

TypeError: latlngs is undefined
{domain}/assets/leaflet.self-45659c657e1c7526f5ad36ed2ca57f9d2689bfcb5c96bc84e276d8b9a9e477b0.js?body=1
Line 5678

The XML looks like it's coming back just fine... is there a playground or sandbox I can use to provide a firm example?

Here is my example call:

var oceans = new L.WFS({ url: 'http://demo.opengeo.org/geoserver/wfs', typeNS: 'maps', typeName: 'ocean', crs: L.CRS.EPSG4326, geometryField: 'the_geom' }).addTo(map);

Here is the response from my call:

<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:nasa="http://nasa.gov" xmlns:ogc="http://www.opengis.net/ogc" xmlns:maps="http://boundlessgeo.com" xmlns:topp="http://www.openplans.org/topp" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ne="http://naturalearthdata.com" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:gml="http://www.opengis.net/gml" xmlns:osm="http://openstreemap.org" xmlns:nurc="http://www.nurc.nato.int" xmlns:og="http://opengeo.org" xmlns:usgs="http://www.usgs.gov/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberOfFeatures="1" timeStamp="2016-03-01T16:12:47.132Z" xsi:schemaLocation="http://boundlessgeo.com http://demo.opengeo.org:80/geoserver/wfs?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=maps%3Aocean http://www.opengis.net/wfs http://demo.opengeo.org:80/geoserver/schemas/wfs/1.1.0/wfs.xsd"> <gml:boundedBy> <gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> <gml:lowerCorner>-180.0 -90.0</gml:lowerCorner> <gml:upperCorner>180.0 90.0</gml:upperCorner> </gml:Envelope> </gml:boundedBy> <gml:featureMembers> <maps:ocean gml:id="ocean.1"> <gml:boundedBy> <gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> <gml:lowerCorner>-180.0 -90.0</gml:lowerCorner> <gml:upperCorner>180.0 90.0</gml:upperCorner> </gml:Envelope> </gml:boundedBy> <maps:the_geom> <gml:MultiSurface srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> <gml:surfaceMember> <gml:Polygon srsDimension="2"> <gml:exterior> <gml:LinearRing srsDimension="2"> <gml:posList>-180.0 -90.0 -180.0 90.0 180.0 90.0 180.0 -90.0 -180.0 -90.0</gml:posList> </gml:LinearRing> </gml:exterior> </gml:Polygon> </gml:surfaceMember> </gml:MultiSurface> </maps:the_geom> <maps:featurecla>Ocean</maps:featurecla> </maps:ocean> </gml:featureMembers> </wfs:FeatureCollection>

Thanks.

Multiple Filters?

Is it possible to include two filters on L.WFST (bbox and eq)?

this method does not work:

filter: new L.Filter.BBox().append(L.latLngBounds(map.getBounds()), 'wkb_geometry', L.CRS.EPSG4326),
filter: new L.Filter.EQ().append('isdeleted', 'f'),

Перетаскивание геометрий

В примерах для полигонов и др. геометрий создаваемых через Leaflet.Editable надо бы добавить возможность перетаскивания.

Bower support

Can you add Bower support too?
How do you add this lib through bower?
bower search Leaflet-WFST gives no results.

need multi-filter,it seems that wfst don't support。

I know someone has an issue about this ,but until now wfst still do not support multi-filter,I don't understand why,it's very usefull .if we don't support ,I have to get jsons and filter myself with for & if statement,that's ugly,beleave me.

Add ability for manual description of FeatureType

Is there support for WFS 2.0.0 ?
Getting an error:

Uncaught TypeError: Cannot read property 'value' of undefined
at e.setFeatureDescription (Leaflet-WFST.src.js:338)
at Object.success (Leaflet-WFST.src.js:1108)
at XMLHttpRequest.xhr.onreadystatechange (Leaflet-WFST.src.js:169)

Custom fields

Hello,

How can I pass custom fields besides Geometry one when inserting/updating feature?

Thanks

geometryField != null

Hi,

Just to report that I have found useful to test for

geometryField != null 

in

generateLayer: function(feature)

so that

responseToLayers: function (rawData)

only adds not null layers.

Otherwise, I sometimes got an error and the code stopped loading other features.

Support: Passing CQL back to Geoserver

Hi, I am loving this library and am trying to push the boundries of what I can do with it, I dont seem to be able to create a CQL filter to pass back to geoserver, is this even possible?

I am trying to have the wfst load a subset of features from geoserver where the attribute "context" is 'foo' that way I can load only "foo" features from the WFS layer during the edit session.

Thanks for any advice or assistance.
Franco

Полигон с отверстием

При сохранении нарисованного с помощью Leaflet.Ediatable полигона с отверстием сохранятся 2 полигона вместо одного с exterior и interior.

Рисую так:

map.editTools.startPolygon();

/* обработчик click полигона */
this.editor.newHole(click.latlng);

Судя по всему, конструкция массива координат видa [ [latlng1, latlng2, ...], [latlng3, latlng4, ...] ] (http://leafletjs.com/reference-1.0.2.html#polygon) неправильно обрабатывается в функции toGml для полигонов, там она воспринимается как два отдельных полигона. Временно решил примерно так:

toGml: function (crs) {
    var polygons = this.getLatLngs();
    var gmlPolygons = [];

    var isSinglePolygon = false;
    for (var i = 0; i < polygons.length; i++) {
      isSinglePolygon = L.Polyline._flat(polygons[i]);
    }

    if (isSinglePolygon) {
      polygons = [polygons];
    }

    for (var i = 0; i < polygons.length; i++) {
    ...

EditPopupToolbar

I'm handling WFST's click event with the following code, like I saw in examples:

wfst.on('click', function (event) {
    new L.EditPopupToolbar(event.latlng).addTo(map, event.layer);
});

The problem is that the EditPopupToolbar only appears in the first click, even debugging and seeing that the event is being fired.

Any ideas?

Thanks in advance

Network error in IE/Edge

Hello,

SCRIPT7002: XMLHttpRequest: Network Error 0x2f78, Could not complete the operation due to error 00002f78.

I get this error in IE/edge. In Chrome and Firefox it works fine.

var DBA_spatial = new L.WFST({
        crs: crs,
        geometryField: 'location',
        url: 'http://192.168.1.169:1112/eoswfs?service=WFS',
        typeNS: 'orbit',
        typeName: 'DBA__1',
        maxZoom: 20,
        minZoom: 1,
    });

Saving Date properties

Saving shapes with Date properties doesn't work at least with my Geoserver 2.10.0 installation. The library successfully parses dates from WFS service, but when I try to save such feature, I get the following response:

Update error: java.lang.String cannot be cast to java.sql.Date

The property in generated transaction request looks like this:

<wfs:Property><wfs:Name>DateCreation</wfs:Name><wfs:Value>Tue Sep 13 1983 03:00:00 GMT+0300 (Russia TZ 2 Standard Time)</wfs:Value></wfs:Property>

Issue with Mapserver 6.4.1 WFS Service

I encounter an issue using Leaflet-WFST with mapserver v 6.4.1 with leaflet in its latest version 1-dev.
It works with default tasmania layer..
When setting my custom wfs, It seems to try to get my layer namespace but can't resolve it.
"Uncaught TypeError: Cannot read property 'value' of undefined"

Here's what I tried
I added the current instruction in my mapfile => "wfs_namespace_prefix" "ms"
Tried to remove typeNS etc..

My code is as below :

 var com_wfs = new L.WFS({
                url: DYNMAP_WS,
                typeNS:  'ms',
                typeName: 'ms:communes_simp',
                crs: L.CRS.EPSG4326,
                geometryField: 'the_geom',
                style: 
                {
                  color: 'blue',
                  weight: 2
                } }, new L.Format.GeoJSON({crs: L.CRS.EPSG4326})).addTo(map);

Ability to Proxy requests

Has there been any thought or discussion as to creating some sort of "proxy" setting to get around CORS? I know that OpenLayers has this feature, I was just wondering if it's been discussed here.

Thanks.

Дозагружать созданные объекты

В ответе wfs:Transaction приходят в т.ч. идентификаторы созданных объектов. Надо удалять созданные слои без feature.id и загружать их заново с помощью полученных идентификаторов.

Uncaught TypeError: Cannot read property 'value' of undefined

When I try this code I'm getting error. I attached the xml file.

xml.txt

new L.WFS({
    url: 'xml.txt',
    typeNS: 'topp',
    typeName: 'tasmania_state_boundaries',
    crs: L.CRS.EPSG4326,
    style: {
        color: 'blue',
        weight: 2
    }
}).addTo(map)
  .on('load', function () {
      map.fitBounds(boundaries);
  })
setFeatureDescription: function (featureInfo) {
    this.namespaceUri = featureInfo.attributes.targetNamespace.value;

targetNamespace.value == null.
"Uncaught TypeError: Cannot read property 'value' of undefined"

Cannot display layer of type MultiLineString

I am using leaflet 0.7.7.

I am grabbing the layer osm:ne_110m_admin_0_boundary_lines_land from http://demo.opengeo.org/geoserver/wfs:

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0" maxFeatures="2" outputFormat="text/xml; subtype=gml/3.1.1"><wfs:Query typeName="osm:ne_110m_admin_0_boundary_lines_land" srsName="EPSG:4326"/></wfs:GetFeature>

The type that's coming back for each FeatureMember is a MultiLineString. For some reason, Leaflet isn't drawing the layer(s) because it cannot parse the list of LatLngs from the XML being returned. From what I can see this the element that contains the coords:

<gml:MultiLineString srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> <gml:lineStringMember> <gml:LineString srsDimension="2"> <gml:posList>-62.84648000000001 -22.034990000000004 -63.98684000000001 -21.99363 -64.37702 -22.79811 -64.96488000000001 -22.07584 -66.27334 -21.83231 -67.10668 -22.73592 -67.82818 -22.8729 -68.21991 -21.49434 -68.75717 -20.372670000000003 -68.44222 -19.40508 -68.96682 -18.98166 -69.10026 -18.26012 -69.59042 -17.58002 -68.95965000000001 -16.500680000000003 -69.38977000000001 -15.660120000000001 -69.16036 -15.32395 -69.33953000000001 -14.9532 -68.94888 -14.45364 -68.92923 -13.60267 -68.88007 -12.899720000000002 -68.66509 -12.56131 -69.52969 -10.9517 -68.78616 -11.03636 -68.27124 -11.014500000000002 -68.04819 -10.712069999999999 -67.1738 -10.30681 -66.64691 -9.9313 -65.33844 -9.76197 -65.44484 -10.511420000000001 -65.32189 -10.89584 -65.40227 -11.56629 -64.31635 -12.462000000000002 -63.1965 -12.627040000000001 -62.803050000000006 -13.000670000000001 -62.12707 -13.198770000000001 -61.71322 -13.48921 -61.084120000000006 -13.47939 -60.50331 -13.77597 -60.459199999999996 -14.35399 -60.26433 -14.64596 -60.25115 -15.07722 -60.54296 -15.093910000000001 -60.15839 -16.25827 -58.24121 -16.29956 -58.38806 -16.87711 -58.28081 -17.27169 -57.734550000000006 -17.55249 -57.498380000000004 -18.17419 -57.676 -18.961850000000002 -57.95 -19.400000000000002 -57.85379 -19.970010000000002 -58.16639000000001 -20.176720000000003 -58.18347000000001 -19.86842 -59.11504 -19.35688 -60.043569999999995 -19.34273 -61.78634 -19.63372 -62.26596000000001 -20.51375 -62.29117 -21.05164 -62.685050000000004 -22.24903 -62.84648000000001 -22.034990000000004</gml:posList> </gml:LineString> </gml:lineStringMember> </gml:MultiLineString>

Inside of L.GML.AbstractMultiPolyline.parse there is a call to L.GML.MultiGeometry.prototype.parse.call This call is returning a an array of LatLng objects. After this happens, a new layer of type L.Polyline is created and setLatLngs is being called with our array of LatLng objects. Inside of this method there is a call to _convertLatLngs with our array. Since this array already contains a list of LatLng objects the method returns NOTHING and then redraw is called on the layer. Sadly, there isn't a list of LatLng objects for the layer and redraw doesn't do anything.

onEachFeature

Is it possible to process each feature separately ?
I know you can with GeoJSON format but I can't figure out how to do this with WFS Layer.
My need is to apply a different style to each feature on mouse hover.
Any ideas ?

Редактирование при клике на объект

Изменить примеры редактирования. Сейчас редактирование всех слоёв включается в document.ready, и в случае с маркерами оно вроде бы не сильно тормозит, то на полигонах просто загибается. Надо сделать кнопку которая включает редактирование слоя при клике на него. Одновременно может редактироваться только один объект.

Bind to Popup - GML

Hi,

Thank you for this great plugin !

Would this be an option to add popup support for GML data ?

a) modify the code by inserting something like this in processFeature:

if (this.options.showPopup == true)
    {
        var mypopup = ""
        for(var k=0; k<this.options.showFields.length; ++k)
        {

            var     name = this.options.showFields[k],
                field= feature.getElementsByTagNameNS(this.namespaceUri, name),
                tc= ""

            if (field[0] != null)   tc =  field[0].textContent   // should be validated / sanitized !!!
            mypopup += "<b>" + name + "</b>: " + tc + "<br>"

            layer.bindPopup(mypopup)
        }
    }

.

b) In initialize, readFormat would become

this.readFormat = readFormat || new L.Format.GML({
      crs: this.options.crs,
      geometryField: this.options.geometryField
      ,showPopup: this.options.showPopup
      ,showFields: this.options.showFields
    });

c) This would enable to simply add

showPopup: true,
showFields:['id', 'name', 'any_other_field']

in the options, so that the popup appears with the selected fields.

Would it be an option ?

как пользоваться typeNS:

геосервер (облачный веб сервис)выдает данные без префикса NameSpace
GetCapabilinies:
FeatureTypeList Operations Query Operations FeatureType Name>kvly</Name Title kv:kv Title Abstract SRS>EPSG:3857</SRS

как в таком случае подключать WFS?

Date format from geoserver

Date, that returned from Geoserver, contains "Z" on end of string, "2015-10-15Z".

  types: ['date', 'time', 'datetime'],
      parse: function (input) {
        return new Date(input);
      }

In Chrome this work good, but in IE11-12, browser cant parse that (invalid date), need to remove "Z".

something like this

if (input[input.length-1] == "Z") {input = input.substring(0, input.length - 1)};
return new Date(input);

Dont sure, is this correct

Using modified WFST

Hi, just to let you know we're using a modified version of WFST on our "geo-explore" tool. It's got some bugfixes and some hacks.. eg. I've changed it to use GET as some WST servers claim to accept POST but don't really.. i've tryed to write it so this could become an option.

I've also added a "guess Geometry" feature which makes a guess at what field contains the geometry.

I've added limited support for gml:MultiGeometry but I don't understand GML well enough to be sure that's correct.

https://github.com/data-ac-uk/geo-explore/commits/master/Leaflet-WFST.src.js

You can see the tool in action at http://geo-explore.ecs.soton.ac.uk/ -- we couldn't have got it working in the time available without Leaflet-WFST so thanks!

These could be worked up into a more formal PULL request if any are of interest to you?

Мультиполигоны и Geoserver 2.10.0

При работе с Geoserver 2.10.0 обнаружил, что при попытке сохранить мультиполигон сохраняется пустая геометрия. Проверив формируемый GML в PostGIS также обнаружил, что он парсится в пустую геометрию. Если заменить тег "MultiPolygon" на "MultiSurface" все работает как следует.

Add maxFeatures

I happen to retrieve 10000 features and my browser crashed.
Do you think maxFeatures should be an option?

Update demo apps

It would be nice to update the example apps with the new leaflet and WFST plugin version.

It will be easier for newcomers to understand how to use the plugin.

Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.