Couche client OGC WFS-T pour le dépliant.
Via npm :
npm i leaflet-wfst --save
Par Bower :
bower i leaflet-wfst --save
Depuis GitHub :
npm i -S git://github.com/Flexberry/Leaflet-WFST.git#v1.1.1
où #v1.1.1 est la version d'une version spécifique.
options: {
crs : L . CRS . EPSG3857 ,
showExisting : true ,
geometryField : 'Shape' ,
url : '' ,
typeNS : '' ,
typeName : '' ,
opacity : 1 ,
style : {
color : 'black' ,
weight : 1
}
}
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 ) ;
nom de l'option | défaut | commentaire |
---|---|---|
crs | L.CRS.EPSG3857 | système de référence spatiale pour la couche, devrait implémenter ICRS, par exemple Proj4Leaflet |
afficherExistant | vrai | charger les entités existantes lors de la création d'une couche |
géométrieChamp | 'Forme' | champ pour stocker les géométries, pour les services non transactionnels peut être omis |
URL | - | URL WFS, par exemple http://demo.opengeo.org/geoserver/osm/ows |
typeNS | - | tapez l'espace de noms |
typeName | - | tapez le nom |
typeNSName | - | tapez le nom de l'espace de noms |
espace de nomsUri | - | URI de l'espace de noms |
opacité | 1 | opacité du calque |
style | - | style vectoriel de dépliant. fonction ou objet |
filtre | - | n'importe quel filtre. voir filtre |
maxFonctionnalités | - | limiter le nombre de fonctionnalités renvoyées |
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 ) ;
} )
Étend les classes de dépliants avec la fonction toGml(crs) :
Déclenche deux types d'événements :
La géométrie des marqueurs écrit en tant que posNode, pour toutes les autres couches, la géométrie écrit en tant que posList
Réalisation de l'encodage du filtre OGC v1.1.0
Les implémentations de filtre renvoient uniquement le contenu interne de l'élément de filtre.
Quelques considérations pour tous les constructeurs de filtres :
Nom | Constructeur |
---|---|
IDENTIFIANT | |
GmlObjectId | L.Filter.GmlObjectId (identifiant de la valeur) |
Comparaisons | |
PropertyIsEqualTo | L.Filter.EQ (propertyExpression firstArgument, literalExpression secondArgument, bool matchCase) |
PropertyIsNotEqualTo | L.Filter.NotEQ (propertyExpression firstArgument, literalExpression secondArgument, bool matchCase) |
La propriété est inférieure à | 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) |
PropriétéEstLike | L.Filter.Like (string propertyName, string likeExpression, attributs d'objet) |
PropriétéEstNull | L.Filter.IsNull (string propertyName) |
La propriété est entre | L.Filter.IsBetween (propertyExpression firstArgument, literalExpression lowerBoundary, literalExpression upperBoundary) |
Opérateurs | |
Ajouter | L.Filter.Add(expression, expression) |
Sous | L.Filter.Sub(expression, expression) |
Mul | L.Filter.Mul(expression, expression) |
Division | L.Filter.Div(expression, expression) |
Logique | |
Et | L.Filter.And(expression[, expression]*) |
Ou | L.Filter.Or(expression[, expression]*) |
Pas | L.Filter.Not(expression) |
Spatial | |
BBox | L.Filter.BBox (string propertyName, limites latLngBounds, ICRS crs) |
Égal | L.Filter.Equals (string propertyName, géométrie de la couche, ICRS crs) |
Disjoint | L.Filter.Disjoint (string propertyName, Géométrie de la couche, ICRS crs) |
Touches | L.Filter.Touches (string propertyName, Géométrie de la couche, ICRS crs) |
Dans | L.Filter.Within (string propertyName, géométrie de la couche, ICRS crs) |
Chevauchements | L.Filter.Overlaps (string propertyName, géométrie de la couche, ICRS crs) |
Croix | L.Filter.Crosses (string propertyName, Géométrie de la couche, ICRS crs) |
Intersecte | L.Filter.Intersects (string propertyName, Géométrie de la couche, ICRS crs) |
Contient | L.Filter.Contains (string propertyName, géométrie de la couche, ICRS crs) |
Tampon de distance spatiale | |
DDans | L.Filter.DWithin (string propertyName, géométrie de la couche, ICRS crs, valeur distance, unités de chaîne) |
Au-delà | L.Filter.Beyond (string propertyName, géométrie de la couche, ICRS crs, valeur distance, unités de chaîne) |
Autre | |
Fonction | L.Filter.Function(string functionName[, expression]*) |
Nom de la propriété | L.Filter.propertyName (nom de chaîne) |
Littéral | L.Filter.literal(valeur) |
PropertyName et Literal sont des fonctions et renvoient directement Gml.
En standard, il existe deux filtres - GmlObjectID et FeatureID, mais le dernier est marqué comme obsolète et n'est donc pas implémenté.
Exemple:
var filter = new L . Filter . GmlObjectID ( 1 ) ;
résultat XML :
< ogc : Filter xmlns : ogc = " http://www.opengis.net/ogc " >
< ogc : GmlObjectId xmlns : gml = " http://www.opengis.net/gml " gml : id = " 1 " />
</ ogc : Filter >
var filter = new L . Filter . EQ ( 'city' , 'Perm' ) ;
filter . toGml ( )
résultat XML :
< ogc : PropertyIsEqualTo >
< ogc : PropertyName >city</ ogc : PropertyName >
< ogc : Literal >Perm</ ogc : Literal >
</ ogc : PropertyIsEqualTo >
Ce filtre accepte les objets d'attributs facultatifs :
attributes: {
wildCard : '*' ,
singleChar : '#' ,
escapeChar : '!' ,
matchCase : true
}
var filter = new L . Filter . Like ( 'city' , '*perm*' , { matchCase : false } ) ;
filter . toGml ( )
résultat XML :
< ogc : ogc:PropertyIsLike wildCard = " * " singleChar = " # " escapeChar = " ! " matchCase = " false " >
< ogc : PropertyName >city</ ogc : PropertyName >
< ogc : Literal >*perm*</ ogc : Literal >
</ ogc : ogc:PropertyIsLike >
Exemple:
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 ( )
résultat 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 >
Exemple:
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 ( ) ;
résultat 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 >
Plugin d'édition - 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 ) ;
} ) ;
pour faire une requête POST "wfs:Transaction", appelez la méthode save(), exemple avec Leaflet.EasyButton
L . easyButton ( 'fa-save' , function ( ) {
wfst . save ( ) ;
} , 'Save changes' ) ;
//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' ] ) ;
démos pour le format de lecture GML
démo pour le format de lecture GeoJSON
filtre de démonstration bbox
Licence MIT