Hi Michaël

thank you for your hint, this is equal to my solution.

// you still have to polygonize your noded linestrings
Polygonizer _polygonizer = new Polygonizer();

list = noder.getNodedSubstrings();
for (Object substring : list) _polygonizer.add(gf.createLineString(((NodedSegmentString)substring).getCoordinates()));

Collection<Polygon> _polygons = _polygonizer.getPolygons();
for (Polygon _p : _polygons) {
          System.out.println(_p);
}

This doesn't work at all.
Sometimes the amout of polyons is correct, but the polygons themselfes not.


Hope that helps

Michaël

Dipl. Inf. Carsten Eider a écrit :
Hi list,

i am getting sick while trying to resolve my problem of splitting a polygon(assumd to have no wholes within),
it is driving me crazy! martin gave the hint:

"Use MCIndexNoder to node the polygon and linestring together, Polygonizer to polygonize the noded edges, and then PointLocater to determine which of the resultant polygons correspond to the input polygon. "

Here is my non working attempt

Polygon p, LineString l;

//Use MCIndexNoder
//Setup intersector any classes implementing SegmentIntersector (InteriorIntersectionFinder <mailbox:///G%7C/Documents%20and%20Settings/Travail/Application%20Data/Thunderbird/Profiles/nwn2wsnb.default/Mail/Local%20Folders/Inbox?number=171338383&header=quotebody&part=1.1.1.2&filename=InteriorIntersectionFinder.html>, IntersectionAdder <mailbox:///G%7C/Documents%20and%20Settings/Travail/Application%20Data/Thunderbird/Profiles/nwn2wsnb.default/Mail/Local%20Folders/Inbox?number=171338383&header=quotebody&part=1.1.1.3&filename=IntersectionAdder.html>, IntersectionFinderAdder <mailbox:///G%7C/Documents%20and%20Settings/Travail/Application%20Data/Thunderbird/Profiles/nwn2wsnb.default/Mail/Local%20Folders/Inbox?number=171338383&header=quotebody&part=1.1.1.4&filename=IntersectionFinderAdder.html>, LineIntersectionAdder <mailbox:///G%7C/Documents%20and%20Settings/Travail/Application%20Data/Thunderbird/Profiles/nwn2wsnb.default/Mail/Local%20Folders/Inbox?number=171338383&header=quotebody&part=1.1.1.5&filename=LineIntersectionAdder.html>, SegmentIntersectionDetector <mailbox:///G%7C/Documents%20and%20Settings/Travail/Application%20Data/Thunderbird/Profiles/nwn2wsnb.default/Mail/Local%20Folders/Inbox?number=171338383&header=quotebody&part=1.1.1.6&filename=SegmentIntersectionDetector.html>) have been tested! SegmentIntersectionDetector _intersector = new SegmentIntersectionDetector(new RobustLineIntersector());
_intersector.setFindProper(true);
_intersector.setFindAllIntersectionTypes(true);

//Wouldn't it be better to setup intersector within the constructor?
MCIndexNoder _mci = new MCIndexNoder();
_mci.setSegmentIntersector(_intersector);
// Add my polygon and my LineString
NodedSegmentString _pseg = new NodedSegmentString(p.getCoordinates(), null); NodedSegmentString _lseg = new NodedSegmentString(l.getCoordinates(), null);
Vector<NodedSegmentString> _v = new Vector<NodedSegmentString>();
//order of adding doesn't alter result
_v.add(_pseg);
_v.add(_lseg);
//lets compute the nodes, whatever this does mean!
_mci.computeNodes(_v);
//here is my polygonizer
Polygonizer _polygonizer = new Polygonizer();
//let's add thsi monotonechains, whatever they mean!
for (Object o : _mci.getMonotoneChains()) {
            MonotoneChain _mtc = (MonotoneChain) o;
             //Convert chain to a linestring, is thsi correct?
LineString _line = _fac.createLineString(_mtc.getCoordinates());
            System.out.println(_line);
            _polygonizer.add(_line);
}
//Here are my hopefully correct poylgons!
Collection<Polygon> _polygons = _polygonizer.getPolygons();
for (Polygon _p : _polygons) {
           /System.out.println(_p);
}

Example 1:
l=LINESTRING (0 0,4 5, 5 4,10 10);
p=POLYGON(0 0,10 0,10 10 ,0 10, 3 8,0 0)
pgsql:<polygon>POLYGON ((10 10, 10 0, 0 0, 4 5, 5 4, 10 10))</polygon><polygon>POLYGON ((0 0, 3 8, 0 10, 10 10, 5 4, 4 5, 0 0))</polygon> jts:<polygon>POLYGON ((5 4, 4 5, 0 0, 3 8, 0 10, 10 10, 5 4))</polygon><polygon>POLYGON ((0 0, 4 5, 5 4, 10 10, 10 0, 0 0))</polygon>

jts==pgsql==>Correct GREAT

Example 2:
l=LINESTRING (-1 -1,4 5, 5 4,11 11);
p=POLYGON(0 0,10 0,10 10 ,0 10, 3 8,0 0)
pgsql:<polygon>POLYGON ((10 9.83333333333333, 10 0, 0 0, 0.136363636363636 0.363636363636364, 4 5, 5 4, 10 9.83333333333333))</polygon><polygon>POLYGON ((0.136363636363636 0.363636363636364, 3 8, 0 10, 10 10, 10 9.83333333333333, 5 4, 4 5, 0.136363636363636 0.363636363636364))</polygon>
jts:<polygon>POLYGON ((0 0, 3 8, 0 10, 10 10, 10 0, 0 0))</polygon>

jts!=pgsql, damn where is my second polygon as expected? why do i get just my original polygon?


Example 3
l=LINESTRING (0 0,4 5, 5 4,10 10,10 6,0 6)
p=POLYGON(0 0,10 0,10 10 ,0 10, 3 8,0 0)
pgsql:<polygon>POLYGON ((10 6, 10 0, 0 0, 4 5, 5 4, 6.66666666666667 6, 10 6))</polygon><polygon>POLYGON ((10 10, 10 6, 6.66666666666667 6, 10 10))</polygon><polygon>POLYGON ((2.25 6, 3 8, 0 10, 10 10, 6.66666666666667 6, 2.25 6))</polygon><polygon>POLYGON ((0 0, 2.25 6, 6.66666666666667 6, 5 4, 4 5, 0 0))</polygon> jts:<polygon>POLYGON ((5 4, 4 5, 0 0, 3 8, 0 10, 10 10, 5 4))</polygon><polygon>POLYGON ((0 0, 4 5, 5 4, 10 10, 10 0, 0 0))</polygon>

jts!=pgsql, why the hell are there only two polygons left? where are the other two as expected?


Any suggestions are very appreciated!
Maybe i should offer a reward of a box of good german beer !

TIA Carsten
--
Mit freundlichen Grüßen / Yours faithfully
Carsten Eider

Dipl. Inf. (FH)

Kompetenzzentrum für Innovative Informationssysteme

c/o Fachhochschhule Bingen / University of applied sciences Bingen

Berlinstraße 109
55411 Bingen

Tel: +49 (0) 6721 / 409-179
Fax: +49 (0) 6721 / 409-158
email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
Internet: iis.fh-bingen.de _______________________________________________
jts-devel mailing list
[email protected]
http://lists.refractions.net/mailman/listinfo/jts-devel

_______________________________________________
jts-devel mailing list
[email protected]
http://lists.refractions.net/mailman/listinfo/jts-devel



_______________________________________________
jts-devel mailing list
[email protected]
http://lists.refractions.net/mailman/listinfo/jts-devel


--
Mit freundlichen Grüßen / Yours faithfully
Carsten Eider

Dipl. Inf. (FH)

Kompetenzzentrum für Innovative Informationssysteme

c/o Fachhochschhule Bingen / University of applied sciences Bingen

Berlinstraße 109
55411 Bingen

Tel: +49 (0) 6721 / 409-179
Fax: +49 (0) 6721 / 409-158
email: [EMAIL PROTECTED]
Internet: iis.fh-bingen.de
begin:vcard
fn:Carsten Eider
n:Eider;Carsten
org:Fachhochschule Bingen;Kompetenzzentrum innovative Informationssysteme
adr;quoted-printable:;;berlinstra=C3=9Fe 109;Bingen;RLP;55411;Deutschland
email;internet:[EMAIL PROTECTED]
title:Dipl.-Inf.
tel;work:067214090179
x-mozilla-html:TRUE
url:iis.fh-bingen.de
version:2.1
end:vcard

_______________________________________________
jts-devel mailing list
[email protected]
http://lists.refractions.net/mailman/listinfo/jts-devel

Reply via email to