Camada cliente OGC WFS-T para folheto.
Via npm:
npm i leaflet-wfst --save
Através do Bower:
bower i leaflet-wfst --save
Do GitHub:
npm i -S git://github.com/Flexberry/Leaflet-WFST.git#v1.1.1
onde #v1.1.1 é a versão do lançamento específico.
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 ) ;
nome da opção | padrão | comentário |
---|---|---|
crs | L.CRS.EPSG3857 | sistema de referência espacial para camada, deve implementar ICRS, por exemplo Proj4Leaflet |
mostrarExistente | verdadeiro | carregar recursos existentes na camada de criação |
GeometriaCampo | 'Forma' | campo para armazenamento de geometrias, para serviços não transacionais pode ser omitido |
url | - | URL WFS, por exemplo http://demo.opengeo.org/geoserver/osm/ows |
tipoNS | - | digite espaço para nome |
tipoNome | - | nome do tipo |
tipoNSNome | - | digite o nome do namespace |
namespaceUri | - | URI do namespace |
opacidade | 1 | opacidade da camada |
estilo | - | estilo de vetor de folheto. função ou objeto |
filtro | - | qualquer filtro. veja filtro |
maxFeatures | - | limitar a quantidade de recursos retornados |
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 ) ;
} )
Estende as classes de folheto com a função toGml(crs):
Aciona dois tipos de eventos:
A geometria dos marcadores escreve como posNode, para todas as outras camadas a geometria escreve como posList
Realização de codificação de filtro OGC v1.1.0
As implementações de filtro retornam apenas o conteúdo interno do elemento de filtro.
Algumas considerações para todos os construtores de filtro:
Nome | Construtor |
---|---|
EU IA | |
GmlObjectID | L.Filter.GmlObjectId(id do valor) |
Comparações | |
PropriedadeIsEqualTo | L.Filter.EQ(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase) |
PropriedadeIsNotEqualTo | L.Filter.NotEQ(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase) |
Propriedade é menor que | L.Filter.LT(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase) |
Propriedade é maior que | L.Filter.GT(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase) |
PropriedadeIsLessThanOrEqualTo | L.Filter.LEQ(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase) |
PropriedadeIsGreaterThanOrEqualTo | L.Filter.GEQ(propertyExpression firstArgument, literalExpression secondArgument, bool matchCase) |
Propriedade é semelhante | L.Filter.Like(string propertyName,string likeExpression,atributos do objeto) |
PropriedadeIsNull | L.Filter.IsNull(string nomedapropriedade) |
Propriedade está entre | L.Filter.IsBetween(propertyExpression firstArgument, literalExpression lowerBoundary, literalExpression UpperBoundary) |
Operadores | |
Adicionar | L.Filter.Add(expressão, expressão) |
Sub | L.Filter.Sub(expressão, expressão) |
Mul | L.Filter.Mul(expressão, expressão) |
Divisão | L.Filter.Div(expressão, expressão) |
Lógica | |
E | L.Filter.And(expressão[, expressão]*) |
Ou | L.Filter.Or(expressão[, expressão]*) |
Não | L.Filter.Not(expressão) |
Espacial | |
BBox | L.Filter.BBox(string propertyName, limites latLngBounds, ICRS crs) |
Igual | L.Filter.Equals(string propertyName, Geometria da camada, ICRS crs) |
Disjunto | L.Filter.Disjoint(string propertyName, Geometria da camada, ICRS crs) |
Toques | L.Filter.Touches(string propertyName, Geometria da camada, ICRS crs) |
Dentro de | L.Filter.Within(string propertyName, Geometria da camada, ICRS crs) |
Sobreposições | L.Filter.Overlaps(string propertyName, Geometria da camada, ICRS crs) |
Cruzes | L.Filter.Crosses(string propertyName, Geometria da camada, ICRS crs) |
Cruza | L.Filter.Intersects(string propertyName, Geometria da camada, ICRS crs) |
Contém | L.Filter.Contains(string propertyName, Geometria da camada, ICRS crs) |
Buffer de distância espacial | |
DDentro | L.Filter.DWithin(string propertyName, geometria da camada, ICRS crs, distância do valor, unidades de string) |
Além | L.Filter.Beyond(string propertyName, geometria da camada, ICRS crs, distância do valor, unidades de string) |
Outro | |
Função | L.Filter.Function(string nomedafunção[, expressão]*) |
Nome da propriedade | L.Filter.propertyName(nome da string) |
Literal | L.Filter.literal(valor) |
PropertyName e Literal são funções e retornam Gml diretamente.
No padrão, existem dois filtros - GmlObjectID e FeatureID, mas o mais recente está marcado como obsoleto e, portanto, não é implementado.
Exemplo:
var filter = new L . Filter . GmlObjectID ( 1 ) ;
resultadoxml:
< 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 ( )
resultadoxml:
< ogc : PropertyIsEqualTo >
< ogc : PropertyName >city</ ogc : PropertyName >
< ogc : Literal >Perm</ ogc : Literal >
</ ogc : PropertyIsEqualTo >
Este filtro aceita atributos opcionais do objeto:
attributes: {
wildCard : '*' ,
singleChar : '#' ,
escapeChar : '!' ,
matchCase : true
}
var filter = new L . Filter . Like ( 'city' , '*perm*' , { matchCase : false } ) ;
filter . toGml ( )
resultadoxml:
< ogc : ogc:PropertyIsLike wildCard = " * " singleChar = " # " escapeChar = " ! " matchCase = " false " >
< ogc : PropertyName >city</ ogc : PropertyName >
< ogc : Literal >*perm*</ ogc : Literal >
</ ogc : ogc:PropertyIsLike >
Exemplo:
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 ( )
resultadoxml:
< 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 >
Exemplo:
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 ( ) ;
resultadoxml:
< 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 de edição - 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 ) ;
} ) ;
para fazer a chamada de solicitação POST "wfs: Transaction" método save(), exemplo com 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' ] ) ;
demonstrações para formato de leitura GML
demonstração para formato de leitura GeoJSON
filtro de demonstração bbox
Licença MIT