[postgis] String to MultiPolygon

Paul Ramsey pramsey at refractions.net
Wed Mar 13 14:10:37 PST 2002


I should point out that I am happy to take patches on the org.postgis
classes, which are suffering from some bit rot and lagging behind Dave's
changes to the canonical representation.
P.

"Ismail Bouabdallah (CS)" wrote:
> 
 
> can anyone help me with the following problem:
> 
> I am trying to convert the string representaion of a MultiPolygon into
> its geometric PostGIS respresentaion in Java.
> 
> 
> 
> 
>  public Vector getSiteBoundaries() {
>     int numberOfRows = resultsTable.getRowCount();
>     Class columnClass;
>     Vector siteBoundaries = new Vector();  // to hold the
> site_boundaries from the current Jtable
>     for (int i = 0; i <numberOfRows; i++) {
>         siteBoundaries.add(resultsTable.getValueAt(i,1));
>         System.out.println("Site_Boundary at " +i+ " is "
> +siteBoundaries.elementAt(i));
>         columnClass = resultsTable.getColumnClass(2);
>         System.out.println("Site_Boundary Column Class is:" + columnClass);
>         String siteBoundaryString = (String)siteBoundaries.elementAt(i);
> 
>         //MultiPolygon siteBoundary =
> (MultiPolygon)siteBoundaries.elementAt(i);
>         //MultiPolygon siteBoundary = MultiPolygon(siteBoundaryString);
> 
>     }
>     return siteBoundaries;
> }
> 
> this is the code that I have written:
> 
>     it grabs the MultiPolygons from a JTable (resultsTable) and then
> stores them in a  vector, at which point they are stored as strings,
> Exception occurred during event dispatching
> 
>     when I try to grab them from the vector I get a ClassCastException
> at runtime, from the line of code : MultiPolygon siteBoundary =
> (MultiPolygon)siteBoundaries.elementAt(i);
> 
>                 java.lang.ClassCastException: java.lang.String at
> canned_classes.QueryToolInterface.getSiteBoundaries(QueryToolInterface.java:261)
> 
>     if I use the line of code: MultiPolygon siteBoundary =
> MultiPolygon(siteBoundaryString);      I get the following runtime error:
> 
>                 QueryToolInterface.java:262: cannot resolve symbol
>                 symbol  : method MultiPolygon  (java.lang.String)
>                 location: class canned_classes.QueryToolInterface
> 
> basically the question I am asking is how do I turn a MultiPolygon as a
> string:
> 
> MULTIPOLYGON(((414699.55 130160.43,414701.83 130149.9,414729.2
> 130155.7,414729.2 130155.7,414733.25 130149.8,414735.1
> 130140.9,414743.75 130142.7,414740.6 130158.15,414742.15
> 130158.5,414739.65 130169.25,414728.05 130166.65,414727.77
> 130167.93,414724.52 130167.19,414717.65 130165.63,414717.85
> 130164.45,414699.55 130160.43)))
> 
> into its geometrical representaion, so I can call the methods of the
> class MultiPolygon in org.postgis on the value:
> 
> does anyone have any advice on this matter...
> 
> Best Regards Ismail
> 
> 
> 
> 
> 
> 
> 
> To unsubscribe from this group, send an email to:
> postgis-unsubscribe at yahoogroups.com
> 
> 
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

-- 
      __
     /
     | Paul Ramsey
     | Refractions Research
     | Email: pramsey at refractions.net
     | Phone: (250) 885-0632
     \_

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Tiny Wireless Camera under $80!
Order Now! FREE VCR Commander!
Click Here - Only 1 Day Left!
http://us.click.yahoo.com/nuyOHD/7.PDAA/yigFAA/PhFolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
postgis-unsubscribe at yahoogroups.com

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 





More information about the postgis-users mailing list