Re: [OpenMap Users] obtain shape from oMGeometry

From: Don Dietrick <dfdietrick_at_gmail.com>
Date: Tue, 26 Jul 2011 12:45:57 -0400

I'd probably do something like this, in OM5 vernacular:

OMGraphicList omgl; // Assume that it has been populated

for (OMGraphic omg : omgl) {

     if (omg instanceof OMPoly) {

               double[] latlonarray = ((OMPoly)omg).getLatLonArray();
               double[] ddLatLonArray = new double[latlonarray.length];
               System.arraycopy(0, latlonarray, 0, ddLatLonArray,
latlonarray.length);
               ProjMath.arrayRadToDeg(ddLatLonArray);
     }
}

- Don

On Tue, Jul 26, 2011 at 12:30 PM, Kevin Grunenberg
<KGrunenberg_at_asascience.com> wrote:
>
> I donšt know if this will work cause I haven't tried it just put it
> together based on the API. There is probably a better way to do it but
> this is what I came up with, maybe another member on the board knows a
> better way.
>
> Point2D p1;
>        OMGeometryList oMGeometryList = new OMGeometryList();
>        for (int x = 0; x < oMGeometryList.size(); x++) {
>
>        //I am not sure this cast will work
>        OMPoly poly = (OMPoly) oMGeometryList.get(x);
>
>        for (int g = 0; g < poly.getLatLonArray().length; g++) {
>                Double x,y
>                y= ProjMath.radToDeg(poly.getLatLonArray()[g]);
>
>                x= ProjMath.radToDeg(poly.getLatLonArray()[g+1]);
>
>                p1 = new Point2D.Double(x,y);
>                g++;
>        }
> }
>
>
>
>
> It could obviously use to be optimized
>
> -Good Luck
> -- Kevin
>
>
> On 7/26/11 10:55 AM, "Schumann B." <Benjamin.Schumann_at_soton.ac.uk> wrote:
>
>>Any idea how to achieve it with OpenMap?
>>I mean, it must be possible to simply read out lat/lon of all points of a
>>shp-file in OpenMap. But I simply cannot figure it out.
>>
>>Thanks for your help (seriously, I do appreciate your efforts).
>>
>>Benjamin Schumann
>>
>>> -----Original Message-----
>>> From: Kevin Grunenberg [mailto:KGrunenberg_at_asascience.com]
>>> Sent: 26 July 2011 16:34
>>> To: Schumann B.
>>> Subject: Re: [OpenMap Users] obtain shape from oMGeometry
>>>
>>> Ben
>>>
>>>      Sorry about that I based that off a class that uses the geotools
>>>library to
>>> read a shp file not the opemap library.
>>>
>>>
>>>
>>> -- Kevin Grunenberg | Programmer
>>> Applied Science Associates
>>> 55 Village Square Drive
>>> South Kingstown, RI 02879
>>> p: 401-789-6224 | f: 401-789-1932
>>>
>>>
>>>
>>>
>>>
>>> On 7/26/11 10:03 AM, "Schumann B." <Benjamin.Schumann_at_soton.ac.uk>
>>> wrote:
>>>
>>> >Hi,
>>> >Thanks for the quick answer.
>>> >I cannot create a class "Geometry". If I replace it by "OMGemoetry", I
>>> >cannot obtain your methods "get(x)", "getNumGeometries" and so on.
>>> >Do I need a special .jar or where can I get the class "Geometry"
>>> >cheers
>>> >Ben
>>> >
>>> >> -----Original Message-----
>>> >> From: Kevin Grunenberg [mailto:KGrunenberg_at_asascience.com]
>>> >> Sent: 26 July 2011 15:42
>>> >> To: openmap-users_at_bbn.com
>>> >> Cc: Schumann B.
>>> >> Subject: Re: [OpenMap Users] obtain shape from oMGeometry
>>> >>
>>> >> 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"]
>

--
[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 - 12:47:17 EDT

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