Re: [OpenMap Users] obtain shape from oMGeometry

From: Kevin Grunenberg <KGrunenberg_at_asascience.com>
Date: Tue, 26 Jul 2011 09:41:36 -0400

Benjamin,

You could try something like this

        Point2D p1;
        for (int x = 0; x < oMGeometryList.size(); x++) {

                Geometry geometry = (Geometry) oMGeometryList.get(x);
                /**
                * The Extra level of looping is to deal with multi polygons
                * If the geometry is a multi-polygon then the coordinate list is ALL
coordinates
                * and they would be connected
                */
                for (int g = 0; g < geometry.getNumGeometries(); g++) {
                        Geometry geo = geometry.getGeometryN(g);
                        Coordinate[] coords = geo.getCoordinates();
                        for (int i = 0; i < coords.length; i++) {
                                p1 = new Point2D.Double(coords[i].x, coords[i].y);
                        }
                }
        }



I hope this helps

-- Kevin




On 7/26/11 9:13 AM, "Schumann B." <Benjamin.Schumann_at_soton.ac.uk> wrote:

>Hi,
>In addition to the path described inmy previous question, I also try to
>follow this path:
>
>1: Access all layers from the map in use:
> Layers = myGisMap.getLayers();
>2: find the political area at the center of the myGisMap:
> politicalArea = layers[0].findPoliticalArea(map.getCenterLongitude(),
>map.getCenterLatitude());
>3: get a OMGeometryList
> oMGeometryList = politicalArea.getGeometry();
>4: get a geometry
> oMGeometry = oMGeometryList.getAt(0);
>
>I do get a geometry and when I run
>"traceln(oMGeometryList.getDescription());" I find something like
>
>"OMGraphicList with 95 OMGraphics
>|--> OMGraphicList with 1 OMGraphic
> |--> OMPoly
>
>|--> OMGraphicList with 1 OMGraphic
> |--> OMPoly "
>
>This list is actually much longer, showing 95 OMGraphics with 153
>OMPolys. So there appears to be something in the oMGeometryList.
>However, when I want to extract an OMGeometry from it using "oMGeometry =
>oMGeometryList.getAt(0);" this oMGeomtry-object has NULL-attributes.
>
>Also, in the API. It says about OMGeometry that "geometry classes are
>intended to pull the object location data out of the OMGraphics.". This
>is what I want, but how?
>
>In principle, I just want to query the shp-file if a certain lat/lon is
>within any shapes/features etc.
>
>Again, I am very interested in any pointers, thanks a lot in advance
>cheers
>
>Benjamin Schumann
>Tel.: 00493091149702
>Mobil: 004915776816125
>Institute for Complex Systems Simulation & Computational Engineering
>Design Group
>School of Engineering Sciences
>University of Southampton (UK)
>Postal Address:
>Damerowstrasse 43c
>13187 Berlin
>Germany
>
>
>--
>[To unsubscribe to this list send an email to "majdart_at_bbn.com"
>with the following text in the BODY of the message "unsubscribe
>openmap-users"]

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Tue Jul 26 2011 - 09:45:12 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:10 EDT