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 | 레이어에 대한 공간 참조 시스템은 Proj4Leaflet과 같은 ICRS를 구현해야 합니다. |
기존 표시 | 진실 | 레이어 생성에 기존 피처 불러오기 |
기하학필드 | '모양' | 비 트랜잭션 서비스의 경우 기하학을 저장하는 필드가 생략될 수 있습니다. |
URL | - | WFS URL(예: http://demo.opengeo.org/geoserver/osm/ows) |
유형NS | - | 유형 네임스페이스 |
유형이름 | - | 유형 이름 |
유형NS이름 | - | 유형 네임스페이스 이름 |
네임스페이스Uri | - | 네임스페이스 URI |
불투명 | 1 | 레이어의 불투명도 |
스타일 | - | 전단지 벡터 스타일입니다. 함수나 객체 |
필터 | - | 어떤 필터. 필터 참조 |
최대 기능 | - | 반환되는 기능의 양을 제한하세요. |
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) 함수를 사용하여 전단지 클래스를 확장합니다.
두 가지 유형의 이벤트를 트리거합니다.
마커 지오메트리는 posNode로 쓰고, 다른 모든 레이어 지오메트리는 posList로 씁니다.
OGC 필터 인코딩 v1.1.0 구현
필터 구현은 필터 요소의 내부 콘텐츠만 반환합니다.
모든 필터 생성자에 대한 몇 가지 고려 사항:
이름 | 건설자 |
---|---|
ID | |
GmlObjectId | L.Filter.GmlObjectId(값 ID) |
비교 | |
PropertyIsEqualTo | L.Filter.EQ(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase) |
PropertyIsNotEqualTo | L.Filter.NotEQ(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase) |
PropertyIsLessTen | L.Filter.LT(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase) |
속성이보다 큼 | L.Filter.GT(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase) |
PropertyIsLessThanOrEqualTo | L.Filter.LEQ(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase) |
속성이 크거나 같음 | L.Filter.GEQ(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase) |
PropertyIsLike | L.Filter.Like(string propertyName,string likeExpression,객체 속성) |
PropertyIsNull | L.Filter.IsNull(문자열 속성 이름) |
PropertyIsBetween | 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(표현식) |
공간 | |
비박스 | L.Filter.BBox(string propertyName, latLngBounds 경계, ICRS crs) |
같음 | L.Filter.Equals(문자열 속성 이름, 레이어 기하학, ICRS crs) |
분리됨 | L.Filter.Disjoint(문자열 속성 이름, 레이어 기하학, ICRS crs) |
접촉 | L.Filter.Touches(문자열 속성 이름, 레이어 기하학, 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라는 두 가지 필터가 있지만 최신은 더 이상 사용되지 않는 것으로 표시되어 구현되지 않습니다.
예:
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 읽기 형식 데모
데모 필터 bbox
MIT 라이센스