[ckan-dev] ckanext-spatial search modification

Dominik Kapišinský dkapisinsky at gmail.com
Fri Nov 13 15:59:22 UTC 2015


that works, but I would like the other direction. It returns packages that
contain whole search box. I want to get packages that are fully contained
by search box (they are inside the search box).


Is there such a function?

Dominik

2015-11-13 15:31 GMT+01:00 Tom Kralidis <tomkralidis at gmail.com>:

> Perhaps try gcontains [1]?
>
> ..Tom
>
> [1]
> https://github.com/geoalchemy/geoalchemy/blob/master/geoalchemy/functions.py#L358
>
> On Fri, Nov 13, 2015 at 8:45 AM, Dominik Kapišinský
> <dkapisinsky at gmail.com> wrote:
> > Hi Tom,
> >
> > thank you for your quick answer.
> > When I try to change intersects to contains, I get the following error:
> >
> > ProgrammingError: (ProgrammingError) operator is not unique: unknown ||
> > geometry LINE 4: ...= package.id AND package_extent.the_geom LIKE '%' ||
> > ST_Geom... ^ HINT: Could not choose a best candidate operator. You might
> > need to add explicit type casts. "SELECT count(*) AS count_1 \nFROM
> (SELECT
> > ST_AsBinary(package_extent.the_geom) AS package_extent_the_geom,
> > package_extent.package_id AS package_extent_package_id \nFROM
> > package_extent, package \nWHERE package_extent.package_id = package.id
> AND
> > package_extent.the_geom LIKE '%%' ||
> ST_GeomFromText(%(ST_GeomFromText_1)s,
> > %(ST_GeomFromText_2)s) || '%%' AND package.state = %(state_1)s) AS
> anon_1"
> > {'ST_GeomFromText_1': 'POLYGON ((18.45703125 48.3562490295, 18.45703125
> > 49.5537255135, 22.587890625 49.5537255135, 22.587890625 48.3562490295,
> > 18.45703125 48.3562490295))', 'state_1': u'active', 'ST_GeomFromText_2':
> > 4326}
> >
> > You can see full log here: http://pastebin.com/iWzreE1U
> >
> > Am I missing something?
> >
> > Dominik
> >
> > 2015-11-13 14:16 GMT+01:00 Tom Kralidis <tomkralidis at gmail.com>:
> >>
> >> On Fri, Nov 13, 2015 at 7:01 AM, Dominik Kapišinský
> >> <dkapisinsky at gmail.com> wrote:
> >> > Hello,
> >> >
> >> > I would like to modify my ckanext-spatial fork to search for something
> >> > like
> >> > contains (if package extent is contained by search box) instead of
> >> > intersection between them. Is it doable?
> >> > I think that I need to change the line in ckanext/spatial/lib/init.py
> :
> >> >
> >> > extents = Session.query(PackageExtent) \
> >> > .filter(PackageExtent.package_id==Package.id) \
> >> > .filter(PackageExtent.the_geom.intersects(input_geometry)) \
> >> > .filter(Package.state==u'active')
> >> >
> >> > Could you help me please?
> >> >
> >>
> >> You can update
> >>
> https://github.com/ckan/ckanext-spatial/blob/master/ckanext/spatial/lib/__init__.py#L153
> >> (changing .intersects to .contains).
> >>
> >> Having said this, it would be great to expose the spatial predicates
> >> to the UI, so a user can (optionally) select what kind of spatial
> >> query they would like (assuming default=intersects).
> >>
> >> ..Tom
> >> _______________________________________________
> >> ckan-dev mailing list
> >> ckan-dev at lists.okfn.org
> >> https://lists.okfn.org/mailman/listinfo/ckan-dev
> >> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
> >
> >
> >
> > _______________________________________________
> > ckan-dev mailing list
> > ckan-dev at lists.okfn.org
> > https://lists.okfn.org/mailman/listinfo/ckan-dev
> > Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
> >
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20151113/95fbf39e/attachment-0003.html>


More information about the ckan-dev mailing list