-
-
Save oscar9/639988a7361cb24606c78291969d3510 to your computer and use it in GitHub Desktop.
Create querys for a FeatureSet #gvsig #scripting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
import gvsig | |
def main(*args): | |
layer = gvsig.currentLayer() | |
store = layer.getFeatureStore() | |
fset0 = store.getFeatureSet() | |
print "Size total: ", fset0.getSize() | |
fset1 = store.getFeatureSet("Campo1>5") | |
print "Filtro con getFeatureSet:", fset1.getSize() | |
query = store.createFeatureQuery() | |
print "query class type: ", type(query) | |
#Orden | |
from org.gvsig.fmap.dal.feature import FeatureQueryOrder | |
order = FeatureQueryOrder() | |
order.add("Campo3", True) | |
query.setOrder(order) | |
# Para crear las expresiones | |
from org.gvsig.app import ApplicationLocator | |
application = ApplicationLocator.getManager() | |
datamanager = application.getDataManager() | |
# Expresion 1 | |
expresion1 = "Campo1>5" | |
filter1 = datamanager.createExpresion(expresion1) | |
query.addFilter(filter1) | |
# Feature set 1 | |
print "Aplicado Filtro 1: ", expresion1 | |
fset4 = store.getFeatureSet(query) | |
print fset4.getSize() | |
# Expresion 2 | |
expresion2 = "Campo2=1" | |
filter2 = datamanager.createExpresion(expresion2) | |
query.addFilter(filter2) | |
# Feature set | |
print "Aplicado Filtro 1: ", expresion1, " y Filtro 2:", expresion2 | |
fset5 = store.getFeatureSet(query) | |
print fset5.getSize() | |
for f in fset5: print f | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment