Leaflet WFST
2.0.0
リーフレットの OGC WFS-T クライアント層。
npm経由:
npm i leaflet-wfst --save
バウワー経由:
bower i leaflet-wfst --save
GitHub から:
npm i -S git://github.com/Flexberry/Leaflet-WFST.git#v1.1.1
ここで、#v1.1.1 は特定のリリースのバージョンです。
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 ) ;
オプション名 | デフォルト | コメント |
---|---|---|
crs | L.CRS.EPSG3857 | レイヤーの空間参照システムは、ICRS を実装する必要があります (Proj4Leaflet など)。 |
show既存の | 真実 | レイヤー作成時に既存のフィーチャをロードする |
ジオメトリフィールド | '形' | ジオメトリを保存するフィールド。非トランザクション サービスの場合は省略できる |
URL | - | WFS URL (例: http://demo.opengeo.org/geoserver/osm/ows) |
NS型 | - | 型名前空間 |
タイプ名 | - | 型名 |
typeNSName | - | 名前空間名を入力します |
名前空間Uri | - | 名前空間URI |
不透明度 | 1 | レイヤーの不透明度 |
スタイル | - | リーフレットのベクトル スタイル。関数またはオブジェクト |
フィルター | - | 任意のフィルター。フィルターを参照 |
maxFeature | - | 返される特徴量を制限する |
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 ) ;
} )
toGml(crs) 関数を使用してリーフレット クラスを拡張します。
2 種類のイベントをトリガーします。
マーカーのジオメトリは posNode として書き込み、他のすべてのレイヤーのジオメトリは posList として書き込みます。
OGCフィルターエンコーディングv1.1.0の実現
フィルター実装は、フィルター要素の内部コンテンツのみを返します。
すべてのフィルター コンストラクターに関する考慮事項:
名前 | コンストラクタ |
---|---|
ID | |
GmlObjectId | L.Filter.GmlObjectId(値ID) |
比較 | |
プロパティは等しい | L.Filter.EQ(propertyExpression firstArgument, literalExpression SecondArgument, bool matchCase) |
プロパティが等しくない | L.Filter.NotEQ(propertyExpression firstArgument, literalExpression SecondArgument, bool matchCase) |
プロパティが未満である | L.Filter.LT(propertyExpression firstArgument, literalExpression SecondArgument, bool matchCase) |
プロパティはより大きい | L.Filter.GT(propertyExpression firstArgument, literalExpression SecondArgument, bool matchCase) |
プロパティが小さいか等しい | L.Filter.LEQ(propertyExpression firstArgument, literalExpression SecondArgument, bool matchCase) |
プロパティが大きいか等しい | L.Filter.GEQ(propertyExpression firstArgument, literalExpression SecondArgument, bool matchCase) |
プロパティは似ています | L.Filter.Like(文字列プロパティ名,文字列 likeExpression,オブジェクト属性) |
プロパティが Null である | L.Filter.IsNull(文字列プロパティ名) |
プロパティは次の間です | L.Filter.IsBetween(propertyExpression firstArgument, literalExpression lowerBoundary, literalExpression upperBoundary) |
オペレーター | |
追加 | L.Filter.Add(式, 式) |
サブ | L.Filter.Sub(式, 式) |
マル | L.Filter.Mul(式, 式) |
ディビジョン | L.Filter.Div(式, 式) |
論理 | |
そして | L.Filter.And(式[, 式]*) |
または | L.Filter.Or(式[, 式]*) |
ない | L.Filter.Not(式) |
空間的 | |
Bボックス | L.Filter.BBox(文字列プロパティ名、latLngBounds境界、ICRS crs) |
等しい | L.Filter.Equals(文字列プロパティ名、レイヤージオメトリ、ICRS crs) |
ばらばら | L.Filter.Disjoint(string propertyName, Layer geometry, ICRS crs) |
タッチ | L.Filter.Touches(string propertyName, Layer geometry, ICRS crs) |
内で | L.Filter.Within(文字列プロパティ名、レイヤージオメトリ、ICRS crs) |
重複 | L.Filter.Overlaps(文字列プロパティ名、レイヤージオメトリ、ICRS crs) |
十字架 | L.Filter.Crosses(文字列プロパティ名、レイヤージオメトリ、ICRS crs) |
交差する | L.Filter.Intersects(文字列プロパティ名、レイヤージオメトリ、ICRS crs) |
含まれています | L.Filter.Contains(文字列プロパティ名、レイヤージオメトリ、ICRS crs) |
空間距離バッファ | |
D範囲内 | L.Filter.DWithin(文字列プロパティ名、レイヤージオメトリ、ICRS crs、値距離、文字列単位) |
超えて | L.Filter.Beyond(文字列プロパティ名、レイヤージオメトリ、ICRS crs、値距離、文字列単位) |
他の | |
関数 | L.Filter.Function(文字列関数名[, 式]*) |
プロパティ名 | L.Filter.propertyName(文字列名) |
リテラル | L.Filter.literal(値) |
PropertyName と Literal は関数であり、Gml を直接返します。
標準では、GmlObjectID と FeatureID という 2 つのフィルターがありますが、latest は非推奨としてマークされているため、実装されていません。
例:
var filter = new L . Filter . GmlObjectID ( 1 ) ;
結果の 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 ( )
結果の XML:
< ogc : PropertyIsEqualTo >
< ogc : PropertyName >city</ ogc : PropertyName >
< ogc : Literal >Perm</ ogc : Literal >
</ ogc : PropertyIsEqualTo >
このフィルターはオプションの属性オブジェクトを受け入れます。
attributes: {
wildCard : '*' ,
singleChar : '#' ,
escapeChar : '!' ,
matchCase : true
}
var filter = new L . Filter . Like ( 'city' , '*perm*' , { matchCase : false } ) ;
filter . toGml ( )
結果の XML:
< ogc : ogc:PropertyIsLike wildCard = " * " singleChar = " # " escapeChar = " ! " matchCase = " false " >
< ogc : PropertyName >city</ ogc : PropertyName >
< ogc : Literal >*perm*</ ogc : Literal >
</ ogc : ogc:PropertyIsLike >
例:
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 ( )
結果の 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 >
例:
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 ( ) ;
結果の 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 >
編集プラグイン - 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 ) ;
} ) ;
"wfs:Transaction" POST リクエストを作成するには、save() メソッドを呼び出します (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' ] ) ;
GML 読み取り形式のデモ
GeoJSON 読み取り形式のデモ
デモフィルターボックス
MITライセンス