Parameters in Queries for Layers

5 views
Skip to first unread message

scottie

unread,
Mar 26, 2019, 11:05:44 AM3/26/19
to GeoScript
Jared,

So,  I noticed the 'params' in the 'options' parameter that gets passed to the getFeatures/getCount/getCursor methods.
And,  I tried to test it out and failed miserably.  I was assuming that it worked kinda like JDBC prepared statements.   Is that
wrong?   Any clues would be great.   Here's my snippet:

import geoscript.workspace.PostGIS


def omardb = new PostGIS('omardb-prod', user: 'postgres')
def f = "file_type=:file_type"


println omardb
['raster_entry']?.count([filter: f, params: [file_type: 'nitf']])


omardb
?.close()






 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Jared Erickson

unread,
Mar 26, 2019, 9:22:55 PM3/26/19
to GeoScript Google Group
Hey Scottie!

I have some tests that go against an H2 database that might help:


and a recipe in my cookbook:


It looks like params are used when dealing with Views.  

I hope this helps!

Jared



--
--
You received this message because you are subscribed to the GeoScript mailing list.
To post to this group, send email to geos...@googlegroups.com
To unsubscribe from this group, send email to geoscript+...@googlegroups.com
Visit this group at http://groups.google.com/group/geoscript or see http://geoscript.org

---
You received this message because you are subscribed to the Google Groups "GeoScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geoscript+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

scottie

unread,
Mar 26, 2019, 11:26:35 PM3/26/19
to GeoScript
Jared,

Thanks for replying.   I guess it doesn't work the way I thought.   But,  this does:

import geoscript.workspace.PostGIS


def omardb = new PostGIS('omardb-prod', user: 'postgres')


def layer = omardb.createView('images_by_file_type',
   
"select * from raster_entry where file_type='%file_type%'",
    omardb
['raster_entry'].schema.geom,
   
params: [['file_type', 'nitf']])


println
"nitfs: ${layer?.count()}"
println
"cadrgs: ${layer?.count(params: [file_type: 'cadrg'])}"
omardb
?.close()

Produces:

nitfs: 7
cadrgs
: 12

Where the contents of my table is:
omardb-prod=# select file_type, count(*) from raster_entry group by file_type order by file_type;
 file_type
| count
-----------+-------
 cadrg    
|    12
 cib      
|     2
 nitf      
|     7
(3 rows)

I'll keep playing around though and let ya know if I come with any other "gotchas" ;-)

Take care and, as always,  you're hard work is appreciated! 

--scottie
Reply all
Reply to author
Forward
0 new messages