annotate gnv-artifacts/src/main/java/de/intevation/gnv/raster/JTSMultiLineStringProducer.java @ 626:61f688a69a55

Split up export modes from output modes. gnv-artifacts/trunk@700 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 23 Feb 2010 11:47:08 +0000
parents 70adafe2b9d5
children b1f5f2a8840f
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;
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
23 /**
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 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
f7038820df2e Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 */
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 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
27 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
28 {
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 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
30 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
31
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 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
33
499
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
34 protected Polygon clip;
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
35
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
36 public JTSMultiLineStringProducer(
499
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
37 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
38 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
39 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
40 ) {
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 this(
499
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
42 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
43 // 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
44 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
45 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
46 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
47 }
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 public JTSMultiLineStringProducer(
499
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
50 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
51 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
52 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
53 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
54 ) {
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 super(minX, minY, maxX, maxY);
499
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
56 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
57 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
58 }
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
499
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
60 protected void clipLineString(
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
61 LineString lineString,
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
62 ArrayList<LineString> lineStrings
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
63 ) {
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
64 if (clip == null) {
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
65 lineStrings.add(lineString);
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
66 return;
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
67 }
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 if (!lineString.intersects(clip)) {
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
70 return;
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
71 }
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 try {
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
74 Geometry result = lineString.intersection(clip);
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
75
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
76 if (result instanceof LineString) {
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
77 lineStrings.add((LineString)result);
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
78 }
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
79 else if (result instanceof MultiLineString) {
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
80 MultiLineString mls = (MultiLineString)result;
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
81 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
82 Geometry g = mls.getGeometryN(i);
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
83 if (g instanceof LineString) {
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
84 lineStrings.add((LineString)g);
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
85 }
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
86 else {
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
87 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
88 }
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 else {
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
92 log.warn("cannot handle " + result.getClass());
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
93 }
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 catch (TopologyException te) {
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
96 log.error(te.getLocalizedMessage(), te);
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
97 lineStrings.add(lineString);
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
98 }
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
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
101 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
102 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
103 ) {
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 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
105 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
106
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 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
108 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
109 ? (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
110 : 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
111
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 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
113 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
114 ? (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
115 : 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
116
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 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
118
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 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
120 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
121
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 // 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
123 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
124 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
125 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
126 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
127 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
128 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
129 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
130 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
131 }
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 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
133 // 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
134 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
135 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
136 m2*(head.a / width) + b2));
499
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
137
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
138 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
139 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
140 coordinates.toArray(
499
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
141 new Coordinate[coordinates.size()])),
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
142 lineStrings);
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
143
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
144 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
145 }
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 // 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
149 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
150
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 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
152 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
153
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 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
155 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
156 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
157 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
158 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
159 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
160 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
161 }
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 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
163 // 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
164 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
165 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
166 m2*(last.b / width) + b2));
499
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
167
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
168 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
169 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
170 coordinates.toArray(
499
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
171 new Coordinate[coordinates.size()])),
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
172 lineStrings);
e065a72f6b62 Clip "Horizontalschnitte" against given clipping polygon.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 498
diff changeset
173
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
174 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
175 } // 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
176 } // 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
177
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 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
179 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
180 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
181 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
182 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
183 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
184 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
185 ? 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
186 : 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
187 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
188 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
189 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
190 }
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 } // 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
192
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 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
194 }
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org