Hi Andrea,
the WKT2Reader has a bug there, the fix is a one liner, but I have to add a
few tests.
You can monitor progress here:
https://osgeo-org.atlassian.net/browse/GEOT-5425
Cheers
Andrea
On Wed, May 25, 2016 at 4:59 PM, Andrea Lai <[email protected]> wrote:
> Hi,
>
>
>
> I am new to geotools. (windows 8.1 – geotols 14.2)
>
>
>
> I am trying to parse this string (WKTReader2)
>
>
>
> "MULTISURFACE (
>
> ((0 0, 1 0, 1 4, 0 0)),
>
> CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 2, 7 5, 2 10), (2 10, 0 2)),
>
> COMPOUNDCURVE (CIRCULARSTRING (3 9, 6 5, 3 2), (3 2, 3 9))))"
>
>
>
> to use it as a Custom WKT Shapes “wkt://” from geoserver
>
>
> “http://docs.geoserver.org/2.8.x/en/user/styling/sld-extensions/pointsymbols.html”
>
>
>
> But I got this Excepiton
>
>
>
>
>
> Exception in thread "main" com.vividsolutions.jts.io.ParseException:
> Expected EMPTY or ( but found '0'
>
> at org.geotools.geometry.jts.WKTReader2.parseError(WKTReader2.java:352)
>
> at
> org.geotools.geometry.jts.WKTReader2.getNextEmptyOrOpener(WKTReader2.java:265)
>
> at org.geotools.geometry.jts.WKTReader2.getCoordinates(WKTReader2.java:168)
>
> at
> org.geotools.geometry.jts.WKTReader2.readLinearRingText(WKTReader2.java:567)
>
> at
> org.geotools.geometry.jts.WKTReader2.readPolygonText(WKTReader2.java:663)
>
> at
> org.geotools.geometry.jts.WKTReader2.readMultiSurfaceText(WKTReader2.java:778)
>
> at
> org.geotools.geometry.jts.WKTReader2.readGeometryTaggedText(WKTReader2.java:420)
>
> at org.geotools.geometry.jts.WKTReader2.read(WKTReader2.java:151)
>
> at org.geotools.geometry.jts.WKTReader2.read(WKTReader2.java:120)
>
> at org.geotools.TestMultiSurface.main(TestMultiSurface.java:120)
>
>
>
>
>
> *I WROTE THIS PROGRAM*
>
>
>
> package org.geotools;
>
>
>
> import com.vividsolutions.jts.geom.*;
>
> import com.vividsolutions.jts.geom.impl.PackedCoordinateSequence;
>
> import com.vividsolutions.jts.io.ParseException;
>
> import org.geotools.geometry.jts.*;
>
>
>
> import java.io.IOException;
>
> import java.util.ArrayList;
>
> import java.util.List;
>
>
>
> /**
>
> * Created by alai on 25/05/2016.
>
> test in POSTGIS:
>
> SELECT ST_Area
>
> (ST_WKTToSQL ('MULTISURFACE (
>
> ((0 0, 1 0, 1 4, 0
> 0)),
>
> CURVEPOLYGON (COMPOUNDCURVE
> (CIRCULARSTRING (0 2, 7 5, 2 10), (2 10, 0 2)),
>
> COMPOUNDCURVE
> (CIRCULARSTRING (3 9, 6 5, 3 2), (3 2, 3 9))))'));
>
>
>
> postgisArea = 31.1602165357206
>
> */
>
>
>
> public class TestMultiSurface {
>
> public static void main(String[] args) throws ParseException,
> IOException {
>
> GeometryFactory geometryFactory =
> JTSFactoryFinder.getGeometryFactory();
>
> CurvedGeometryFactory curvedFactory = new
> CurvedGeometryFactory(geometryFactory, Double.MAX_VALUE);
>
>
>
> // B: - arc+line = exterior CounterClockwise
>
> PackedCoordinateSequence coords_arc_B = new
> PackedCoordinateSequence.Double(
>
> new double[]{0, 2, 7, 5, 2, 10}, 2);
>
>
>
> Coordinate[] coords_line_B = new Coordinate[]{new Coordinate(2,
> 10), new Coordinate(0, 2)};
>
>
>
> CircularString arc_B = (CircularString)
> curvedFactory.createCurvedGeometry(coords_arc_B);
>
> LineString line_B =
> geometryFactory.createLineString(coords_line_B);
>
>
>
> List<LineString> list_B = new ArrayList<>();
>
> list_B.add(arc_B);
>
> list_B.add(line_B);
>
>
>
> CompoundRing ring_B = (CompoundRing)
> curvedFactory.createCurvedGeometry(list_B);
>
>
>
> // C: - arc+line = holes Clockwise
>
> PackedCoordinateSequence coords_arc_C = new
> PackedCoordinateSequence.Double(
>
> new double[]{3, 9, 6, 5, 3, 2}, 2);
>
>
>
> Coordinate[] coords_line_C = new Coordinate[]
>
> {new Coordinate(3, 2), new Coordinate(3, 9)};
>
>
>
> CircularString arc_C = (CircularString)
> curvedFactory.createCurvedGeometry(coords_arc_C);
>
> LineString line_C =
> geometryFactory.createLineString(coords_line_C);
>
>
>
> List<LineString> list_C = new ArrayList<>();
>
> list_C.add(arc_C);
>
> list_C.add(line_C);
>
>
>
> CompoundRing ring_C = (CompoundRing)
> curvedFactory.createCurvedGeometry(list_C);
>
>
>
> // curve polygon BC
>
> Polygon poly_BC = curvedFactory.createCurvePolygon(ring_B, new
> LinearRing[]{ring_C});
>
>
>
> // A: polygon
>
> Coordinate[] coords_poly_A = new Coordinate[]
>
> {new Coordinate(0, 0), new Coordinate(1, 0), new
> Coordinate(1, 4), new Coordinate(0, 0)};
>
>
>
> Polygon poly_A = geometryFactory.createPolygon(coords_poly_A);
>
>
>
> // MultiSurface_A_BC
>
> List<Polygon> polygons = new ArrayList<>();
>
> polygons.add(poly_A);
>
> polygons.add(poly_BC);
>
>
>
> MultiSurface multiSurface_A_BC = (MultiSurface)
> curvedFactory.createMultiSurface(polygons);
>
>
>
> // write
>
> WKTWriter2 wktWriter2 = new WKTWriter2();
>
> String WKT2 = wktWriter2.write(multiSurface_A_BC);
>
>
>
> // reader
>
> WKTReader2 wktReader2 = new WKTReader2(curvedFactory);
>
>
>
> // CREATE EXCEPTION -> NOT WORKING
>
> MultiSurface multisurface_from_wkt2 = (MultiSurface)
> wktReader2.read(WKT2);// ERROR
>
>
>
> System.out.println("multiSurface_A_BC: valid? = " +
> multiSurface_A_BC.isValid());
>
> System.out.println("Area = " + multiSurface_A_BC.getArea()); //
> Area = 31.110026267242873
>
> System.out.println("\n" +
> wktWriter2.writeFormatted(multiSurface_A_BC));
>
> }
>
> }
>
> *Thanks*
>
> *Andrea Lai*
>
>
>
>
> ------------------------------------------------------------------------------
> Mobile security can be enabling, not merely restricting. Employees who
> bring their own devices (BYOD) to work are irked by the imposition of MDM
> restrictions. Mobile Device Manager Plus allows you to control only the
> apps on BYO-devices by containerizing them, leaving personal data
> untouched!
> https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
> _______________________________________________
> GeoTools-GT2-Users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
--
==
GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information.
==
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it
*AVVERTENZE AI SENSI DEL D.Lgs. 196/2003*
Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.
The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.
-------------------------------------------------------
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users