Get all features in a layer?

Topics: SharpMap v0.9 / v1.x
Mar 14, 2008 at 7:47 PM
I'm using SharpMap 0.9. I have several layers (all VectorLayer), each of which uses the MsSqlSpatial provider. Is there an easy way to have the provider return all features in that layer, preferably as FeatureDataRow objects?
Mar 18, 2008 at 4:08 PM
I ended up writing an entirely new method on MsSqlSpatial. I hate to do that, but I don't see any other obvious way of doing it.

For a bit, I was trying to use GetFeature(uint rowID), but I could never get this call to return anything.
Coordinator
Mar 18, 2008 at 5:58 PM
There is no ExecuteIntersectionQuery() to which you could pass the layer extents?
Mar 19, 2008 at 3:02 AM
Yes, there is ExecuteIntersectionQuery, although I'm not totally certain how I'd get the layer extents. And this seems like an odd way to return all features in a layer, since I don't really care about intersection.

I'll give your method a try. Thanks.
Mar 19, 2008 at 8:38 AM
Hi, i also use mssqlspatial provider, i use ExecuteIntersectionQuery(). but it give me this error message Invalid object name 'ST.FilterQuery#dbo#organize#thegeom'._
i use this spatial query directly in SQL SERVER, it can not work too.

if i use the following query sentence, it works.
select t.NAME, ST.AsText(t.thegeom)
from ST.IsWithinDistanceQuery('gPlaceNames', 'the_geom', (
select the_geom from gPlaceNames where NAME='CRONULLA'
), 0.05) AS q
inner join gPlaceNames as t on q.oid = t.oid_

i do not know why ? can anyone help me ?
Coordinator
Mar 19, 2008 at 4:58 PM
There should be a function called GetExtents() on the provider.

In general, with a spatial query, you are doing an intersection (or, less commonly, some other spatial predicate, like disjoint).

There currently isn't support for attribute-based queries without also doing a spatial query, although it has been asked for before. I looked and can't find a work item for it... you think there should be?
Mar 20, 2008 at 2:10 AM

codekaizen wrote:
There should be a function called GetExtents() on the provider.

In general, with a spatial query, you are doing an intersection (or, less commonly, some other spatial predicate, like disjoint).

There currently isn't support for attribute-based queries without also doing a spatial query, although it has been asked for before. I looked and can't find a work item for it... you think there should be?


Good question. I think there probably should be a general work item to do attribute-based queries in addition to spatial queries, but I don't know that I'd consider it a high priority.

I'm not as familiar with the data model in 2.0 as I am with 0.9, but it'd be good if 0.9 data providers implemented IAttributeQuery or IGenericQuery (or whatever) where it was appropriate. I don't know if it'd make any sense on a shapefile provider (maybe it would--I dunno--not familiar enough with the domain here to say with any certainty), but there's a lot of instances where an application wants the data associated with a given feature and doesn't really care about any of the spatial properties.

We did end up going with 0.9 for our application, mostly due to 2.0 still being in a state of flux, but I'm hoping to be able to contribute to 2.0 at some later date. I might have time to think about attribute-based queries in a couple months.
Editor
Feb 5, 2010 at 9:38 PM

Attribute based queries are just as important as spatial queries.  If the above is true it would explain why I've been beating my head against my desk trying to get this done.

Here is a common of use cases for an attribute based query:

Application to find a location on a map.  User types "Domino's Pizza" the application looks in the name field and puts pins on the map indicating where all of the 'Domino's Pizza parlors are.  More specifically, user searches for "Big Momma's Little Kitchen" restaurant.  The application selects "Big Momma's Little Kitchen".

Replace pizza parlors with; parcel identifiers in a cadastral application, forest cover types in a forestry application, etc.

In the application I am working on, the users will be editing non-spatial information and I need to show them where, spatially on a map, the object that they are working on resides.  This means that I have non-spatial identifiers that I need to be able to query that shape file with to locate the object in question.  Nothing spatial about it.  No intersects, no contains, no completely within.

It appears that the only way to get access to the table underlying a vector layer is to run a dummy spatial query against it.  Is this true?

 

 

 

 

 

 

 

 

 

Coordinator
Feb 6, 2010 at 2:45 AM

Most if not all providers have either a FilterDelegate or DefinitionQuery property which can be used for attribute based filters. You still have a spatial component to the search but it can be the layer extent if you want it to be. hth jd