Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/raster/JTSMultiLineStringProducer.java @ 795:cdade5005cba
Added javadoc in jfreechart package.
gnv-artifacts/trunk@877 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 31 Mar 2010 13:48:07 +0000 |
parents | c4156275c1e1 |
children | 4abe172be970 |
rev | line source |
---|---|
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.gnv.raster; |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
3 import com.vividsolutions.jts.geom.Coordinate; |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
4 import com.vividsolutions.jts.geom.Geometry; |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
5 import com.vividsolutions.jts.geom.GeometryFactory; |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
6 import com.vividsolutions.jts.geom.LineString; |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
7 import com.vividsolutions.jts.geom.MultiLineString; |
501
70adafe2b9d5
Speed up the "Horizontalschnitte"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
499
diff
changeset
|
8 import com.vividsolutions.jts.geom.Polygon; |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
9 import com.vividsolutions.jts.geom.TopologyException; |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
11 import de.intevation.gnv.math.IJKey; |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.gnv.raster.Vectorizer.Edge; |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.gnv.utils.Pair; |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
17 import gnu.trove.TIntObjectHashMap; |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
19 import java.util.ArrayList; |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
20 import java.util.List; |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
21 |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
22 import org.apache.log4j.Logger; |
779
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
501
diff
changeset
|
23 |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 /** |
780
c4156275c1e1
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
779
diff
changeset
|
25 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 */ |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 public class JTSMultiLineStringProducer |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 extends IsoProducer |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 { |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 private static Logger log = Logger.getLogger( |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 JTSMultiLineStringProducer.class); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 protected GeometryFactory geometryFactory; |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
35 protected Polygon clip; |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
36 |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 public JTSMultiLineStringProducer( |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
38 Polygon clip, |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 double minX, double minY, |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 double maxX, double maxY |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 ) { |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 this( |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
43 clip, |
498
4080b57dcb52
Upgraded to Geotools 2.5.8. Write polygons and line strings to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
465
diff
changeset
|
44 // XXX: Geotools crashes if only using a 2d packed data format! |
4080b57dcb52
Upgraded to Geotools 2.5.8. Write polygons and line strings to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
465
diff
changeset
|
45 JTSMultiPolygonProducer.createDefaultGeometryFactory(3), |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 minX, minY, |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 maxX, maxY); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 } |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 public JTSMultiLineStringProducer( |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
51 Polygon clip, |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 GeometryFactory geometryFactory, |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 double minX, double minY, |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 double maxX, double maxY |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 ) { |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 super(minX, minY, maxX, maxY); |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
57 this.clip = clip; |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 this.geometryFactory = geometryFactory; |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 } |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
61 protected void clipLineString( |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
62 LineString lineString, |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
63 ArrayList<LineString> lineStrings |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
64 ) { |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
65 if (clip == null) { |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
66 lineStrings.add(lineString); |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
67 return; |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
68 } |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
69 |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
70 if (!lineString.intersects(clip)) { |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
71 return; |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
72 } |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
73 |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
74 try { |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
75 Geometry result = lineString.intersection(clip); |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
76 |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
77 if (result instanceof LineString) { |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
78 lineStrings.add((LineString)result); |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
79 } |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
80 else if (result instanceof MultiLineString) { |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
81 MultiLineString mls = (MultiLineString)result; |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
82 for (int i = 0, N = mls.getNumGeometries(); i < N; ++i) { |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
83 Geometry g = mls.getGeometryN(i); |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
84 if (g instanceof LineString) { |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
85 lineStrings.add((LineString)g); |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
86 } |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
87 else { |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
88 log.warn("cannot handle geometry " + g.getClass()); |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
89 } |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
90 } |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
91 } |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
92 else { |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
93 log.warn("cannot handle " + result.getClass()); |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
94 } |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
95 } |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
96 catch (TopologyException te) { |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
97 log.error(te.getLocalizedMessage(), te); |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
98 lineStrings.add(lineString); |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
99 } |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
100 } |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
101 |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 public List<Pair<Object, MultiLineString>> getMultiLineStrings( |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 AttributeGenerator attributeGenerator |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 ) { |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 ArrayList<Pair<Object, MultiLineString>> multiLineStrings = |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 new ArrayList<Pair<Object, MultiLineString>>(); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 double b1 = minX; |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 double m1 = width != 1 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 ? (maxX - minX)/(width-1) |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 : 0d; |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 double b2 = minY; |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 double m2 = height != 1 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 ? (maxY - minY)/(height-1) |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 : 0d; |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 ArrayList<Coordinate> coordinates = new ArrayList<Coordinate>(); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 for (IJKey key: joinPairs()) { |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 ArrayList<LineString> lineStrings = new ArrayList<LineString>(); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 // process complete |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 ArrayList<Edge> completeList = complete.get(key); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 if (completeList != null) { |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 for (Edge head: completeList) { |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 Edge current = head; |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
128 do { |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
129 coordinates.add(new Coordinate( |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
130 m1*(current.a % width) + b1, |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
131 m2*(current.a / width) + b2)); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 } |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
133 while ((current = current.next) != head); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
134 // add head again to close shape |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
135 coordinates.add(new Coordinate( |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
136 m1*(head.a % width) + b1, |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
137 m2*(head.a / width) + b2)); |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
138 |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
139 clipLineString( |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 geometryFactory.createLineString( |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 coordinates.toArray( |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
142 new Coordinate[coordinates.size()])), |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
143 lineStrings); |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
144 |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 coordinates.clear(); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 } |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 } |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 // process open |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
150 TIntObjectHashMap map = commonOpen.get(key); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
151 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
152 if (map != null) { |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
153 for (Edge head: headList(map)) { |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
154 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 head = Vectorizer.simplify(head, width); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 Edge current = head, last = head; |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
157 do { |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
158 coordinates.add(new Coordinate( |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
159 m1*(current.a % width) + b1, |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
160 m2*(current.a / width) + b2)); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
161 last = current; |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
162 } |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
163 while ((current = current.next) != null); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
164 // add b from tail |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
165 coordinates.add(new Coordinate( |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
166 m1*(last.b % width) + b1, |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
167 m2*(last.b / width) + b2)); |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
168 |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
169 clipLineString( |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
170 geometryFactory.createLineString( |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
171 coordinates.toArray( |
499
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
172 new Coordinate[coordinates.size()])), |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
173 lineStrings); |
e065a72f6b62
Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
498
diff
changeset
|
174 |
465
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 coordinates.clear(); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
176 } // for all in common open |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
177 } // if map defined for key |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
178 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
179 if (!lineStrings.isEmpty()) { |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
180 MultiLineString multiLineString = |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
181 geometryFactory.createMultiLineString( |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
182 lineStrings.toArray( |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
183 new LineString[lineStrings.size()])); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
184 lineStrings.clear(); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
185 Object attribute = attributeGenerator != null |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
186 ? attributeGenerator.generateAttribute(key.i, key.j) |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
187 : key; |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
188 multiLineStrings.add(new Pair<Object, MultiLineString>( |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
189 attribute, |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
190 multiLineString)); |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
191 } |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
192 } // for all pairs |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
193 |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
194 return multiLineStrings; |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
195 } |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
196 } |
f7038820df2e
Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
197 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |