Java Mapserver app - queryLayerByPoint. How?

Umberto Nicoletti umberto.nicoletti at GMAIL.COM
Wed Nov 14 07:02:07 EST 2007


The code snippet is actually missing the code for this function which
does the trick of fetching a shape's value and putting them into a map
for later use:

    protected Map getResult(shapeObj shape, layerObj layer) {
        Map aResult = new HashMap();
        for (int z = 0; z < shape.getNumvalues(); z++) {
            aResult.put(layer.getItem(z), shape.getValue(z));
        }
        return aResult;
    }

Regards,
Umberto

On Nov 14, 2007 12:36 PM, Jeresin <info at jeresin.co.za> wrote:
> Umberto Nicoletti wrote:
> >
> > There is a queryByPoint code example here (before last paragraph):
> >
> > http://mapserver.gis.umn.edu/docs/howto/javamapscript
> >
> > HTH,
> > Umberto
> >
> >
>
>
> Hi Umberto, thanks for the reply
>
> Yes, I'm using code very similar to that to query my layers...and I'm
> getting results back from the layers. What I'd like to know if is there a
> way of obtaining the data associated with the returned results? Let me give
> you a clear example:
>
> On a layer called "TOWNS" there are points (towns) as appearing in a .map
> file. The TOWNS.shp file provides me with the actual points. However, there
> is a TOWNS.dbf file which contains the town name, the population, the
> addresses of certain facilities, and so on. It's *that* data that I want to
> access and display.
>
> Currently, when I query the layer, I do get the shape (town) and I can get
> the coordinates of the point, the shape index, and so on. That's no problem.
> However, I would like to get hold of that *other* data, contained in the
> .dbf file. Obviously the data is accessible, hence the fact that I can
> display labels as text from the dbf, but I don't see a clear link between a
> point query on the map and that data...perhaps by CLASSITEMs but that seems
> an expensive work-around. As you see by my guessing, I clearly have no idea
> ;) The one solution - one that has been working but which I'd prefer /not/
> to use - is by getting the shape index from the layer query and then, using
> a 3rd party Java library, obtaining the data from the dbf file and matching
> data sets with map entities. I'd actually prefer not to use the additional
> library at all, it just feels so wrong.
>
> Hope you understand my dilemma now, hope you can help...
> --
> View this message in context: http://www.nabble.com/Java-Mapserver-app---queryLayerByPoint.-How--tf4800141.html#a13745007
>
> Sent from the Mapserver - User mailing list archive at Nabble.com.
>



More information about the mapserver-users mailing list