OGC WFS-T-Client-Schicht für Broschüren.
Über npm:
npm i leaflet-wfst --save
Über Bower:
bower i leaflet-wfst --save
Von GitHub:
npm i -S git://github.com/Flexberry/Leaflet-WFST.git#v1.1.1
Dabei ist #v1.1.1 die Version einer bestimmten Version.
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 ) ;
Optionsname | Standard | Kommentar |
---|---|---|
crs | L.CRS.EPSG3857 | Raumbezugssystem für Layer, sollte ICRS implementieren, zum Beispiel Proj4Leaflet |
showExisting | WAHR | Laden Sie vorhandene Features auf die Ebene erstellen |
GeometrieFeld | 'Form' | Feld zum Speichern von Geometrien, für Nicht-Transaktionsdienste kann weggelassen werden |
URL | - | WFS-URL, zum Beispiel http://demo.opengeo.org/geoserver/osm/ows |
TypNS | - | Geben Sie einen Namensraum ein |
Typname | - | Typname |
TypNSName | - | Geben Sie den Namespace-Namen ein |
NamespaceUri | - | Namespace-URI |
Opazität | 1 | Deckkraft der Ebene |
Stil | - | Broschüren-Vektorstil. Funktion oder Objekt |
Filter | - | irgendein Filter. siehe Filter |
maxFeatures | - | Begrenzen Sie die Anzahl der zurückgegebenen Funktionen |
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 ) ;
} )
Erweitert Leaflet-Klassen mit der Funktion toGml(crs):
Löst zwei Arten von Ereignissen aus:
Markierungsgeometrie schreibt als posNode, für alle anderen Ebenen schreibt die Geometrie als posList
Realisierung von OGC Filter Encoding v1.1.0
Filterimplementierungen geben nur den inneren Inhalt des Filterelements zurück.
Einige Überlegungen für alle Filterkonstruktoren:
Name | Konstrukteur |
---|---|
AUSWEIS | |
GmlObjectId | L.Filter.GmlObjectId(Wert-ID) |
Vergleiche | |
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) |
Betreiber | |
Hinzufügen | L.Filter.Add(Ausdruck, Ausdruck) |
Sub | L.Filter.Sub(Ausdruck, Ausdruck) |
Mul | L.Filter.Mul(Ausdruck, Ausdruck) |
Abt | L.Filter.Div(Ausdruck, Ausdruck) |
Logik | |
Und | L.Filter.And(Ausdruck[, Ausdruck]*) |
Oder | L.Filter.Or(Ausdruck[, Ausdruck]*) |
Nicht | L.Filter.Not(Ausdruck) |
Räumlich | |
BBox | L.Filter.BBox(string propertyName, latLngBounds-Grenzen, ICRS crs) |
Gleich | L.Filter.Equals(string propertyName, Layer Geometry, ICRS crs) |
Disjunkt | L.Filter.Disjoint(string propertyName, Layer Geometry, ICRS crs) |
Berührungen | L.Filter.Touches(string propertyName, Layer Geometry, ICRS crs) |
Innerhalb | L.Filter.Within(string propertyName, Layer Geometry, ICRS crs) |
Überschneidungen | L.Filter.Overlaps(string propertyName, Layer Geometry, ICRS crs) |
Kreuze | L.Filter.Crosses(string propertyName, Layer Geometry, ICRS crs) |
Schnittmengen | L.Filter.Intersects(string propertyName, Layergeometrie, ICRS crs) |
Enthält | L.Filter.Contains(string propertyName, Layer Geometry, ICRS crs) |
Räumlicher Abstandspuffer | |
Innerhalb | L.Filter.DWithin(string propertyName, Layergeometrie, ICRS crs, Wertabstand, Stringeinheiten) |
Darüber hinaus | L.Filter.Beyond(string propertyName, Layergeometrie, ICRS crs, Wertabstand, Stringeinheiten) |
Andere | |
Funktion | L.Filter.Function(string functionName[, expression]*) |
Eigenschaftsname | L.Filter.propertyName(String-Name) |
Wörtlich | L.Filter.literal(Wert) |
PropertyName und Literal sind Funktionen und geben Gml direkt zurück.
Im Standard gibt es zwei Filter – GmlObjectID und FeatureID, aber „latest“ ist als veraltet markiert und daher nicht implementiert.
Beispiel:
var filter = new L . Filter . GmlObjectID ( 1 ) ;
Ergebnis-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 ( )
Ergebnis-XML:
< ogc : PropertyIsEqualTo >
< ogc : PropertyName >city</ ogc : PropertyName >
< ogc : Literal >Perm</ ogc : Literal >
</ ogc : PropertyIsEqualTo >
Dieser Filter akzeptiert optionale Objektattribute:
attributes: {
wildCard : '*' ,
singleChar : '#' ,
escapeChar : '!' ,
matchCase : true
}
var filter = new L . Filter . Like ( 'city' , '*perm*' , { matchCase : false } ) ;
filter . toGml ( )
Ergebnis-XML:
< ogc : ogc:PropertyIsLike wildCard = " * " singleChar = " # " escapeChar = " ! " matchCase = " false " >
< ogc : PropertyName >city</ ogc : PropertyName >
< ogc : Literal >*perm*</ ogc : Literal >
</ ogc : ogc:PropertyIsLike >
Beispiel:
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 ( )
Ergebnis-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 >
Beispiel:
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 ( ) ;
Ergebnis-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 >
Bearbeitungs-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 ) ;
} ) ;
Um die POST-Anfrage „wfs:Transaction“ zu erstellen, rufen Sie die Methode save() auf, Beispiel mit 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' ] ) ;
Demos für das GML-Leseformat
Demo für das GeoJSON-Leseformat
Demofilter Bbox
MIT-Lizenz