Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have been struggling with something for a while that I figured would be simple. I have a WMS layer with many (millions) polygon features. This is a PostGIS layer (WMS). Each polygon has an ID in an attribute. I have a web page set up where a user can enter an ID and click a Search button. I would like the interface to find the polygon and zoom to it. With the research I have been doing, it appears I need to do this using a WMS layer. I have tried to import the layer as a WFS and it does not seem to be working.

My question is two part.

1) Do I need to do this with a WFS or can I stick with WMS?

2) Do you have any samples of code to do this with the data coming from this PostGIS store? I hate asking someone else to write the code, but if you can use what I put down below, that would be great just because I have been banging my head. I'm a .NET desktop programmer so this has been a learning curve.

Thanks for your help!

share|improve this question
    
Please I can help whit a sample ... –  user16443 Mar 22 '13 at 20:00
add comment

1 Answer 1

With a Million polygons, you really shouldn't use the WFS layer for Display. You should stick to the WMS Layer, since it comes as an image(so less data is transferred over the network), and less memory is consumed on the Client side.

Now coming to the search functionality. How are you doing the search? I guess the User enters the ID, and you want to zoom to the the polygon with that ID.

The best way to do this, is to have an empty vector layer in your OpenLayers Application Above your WMS layer, and send a WFS Get Feature Request like this:

http://example.com/geoserver/wfs?
service=wfs&
version=2.0.0&
request=GetFeature&
typeName=namespace:featuretype&
featureID=feature&
outputFormat=json

Once you get the geometry back, you can then zoom into the point, and add the selected polygon to the vector layer.

share|improve this answer
    
Thanks for that. I was playing around a little this weekend and still was not able to get it to work. I must just be doing something small wrong and I don't see it because this is all pretty unfamiliar to me. If you don't mind, is there any chance I could ask you to show me what this would look like to retrieve a single state from the standards usa states layer that comes with geoserver? Thanks very much for your help. This is certainly pointing me in the right direction. –  Jared Feb 11 '13 at 19:41
    
@Jared I'll try to show an example in a day or two. –  Devdatta Tengshe Feb 13 '13 at 3:15
    
Ok, great. Thank you! –  Jared Feb 17 '13 at 17:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.