source: osm/applications/editors/josm/plugins/opendata/includes/com/vividsolutions/jts/geom/MultiLineString.java@ 28000

Last change on this file since 28000 was 28000, checked in by donvip, 12 years ago

Import new "opendata" JOSM plugin

File size: 3.6 KB
Line 
1/*
2 * The JTS Topology Suite is a collection of Java classes that
3 * implement the fundamental operations required to validate a given
4 * geo-spatial data set to a known topological specification.
5 *
6 * Copyright (C) 2001 Vivid Solutions
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * For more information, contact:
23 *
24 * Vivid Solutions
25 * Suite #1A
26 * 2328 Government Street
27 * Victoria BC V8T 5G5
28 * Canada
29 *
30 * (250)385-6040
31 * www.vividsolutions.com
32 */
33package com.vividsolutions.jts.geom;
34
35import com.vividsolutions.jts.operation.BoundaryOp;
36
37/**
38 * Models a collection of (@link LineString}s.
39 * <p>
40 * Any collection of LineStrings is a valid MultiLineString.
41 *
42 *@version 1.7
43 */
44public class MultiLineString
45 extends GeometryCollection
46 implements Lineal
47 {
48 private static final long serialVersionUID = 8166665132445433741L;
49
50 /**
51 * @param lineStrings
52 * the <code>LineString</code>s for this <code>MultiLineString</code>,
53 * or <code>null</code> or an empty array to create the empty
54 * geometry. Elements may be empty <code>LineString</code>s,
55 * but not <code>null</code>s.
56 */
57 public MultiLineString(LineString[] lineStrings, GeometryFactory factory) {
58 super(lineStrings, factory);
59 }
60
61 public int getDimension() {
62 return 1;
63 }
64
65 public int getBoundaryDimension() {
66 if (isClosed()) {
67 return Dimension.FALSE;
68 }
69 return 0;
70 }
71
72 public String getGeometryType() {
73 return "MultiLineString";
74 }
75
76 public boolean isClosed() {
77 if (isEmpty()) {
78 return false;
79 }
80 for (int i = 0; i < geometries.length; i++) {
81 if (!((LineString) geometries[i]).isClosed()) {
82 return false;
83 }
84 }
85 return true;
86 }
87
88 /**
89 * Gets the boundary of this geometry.
90 * The boundary of a lineal geometry is always a zero-dimensional geometry (which may be empty).
91 *
92 * @return the boundary geometry
93 * @see Geometry#getBoundary
94 */
95 public Geometry getBoundary()
96 {
97 return (new BoundaryOp(this)).getBoundary();
98 }
99
100 /**
101 * Creates a {@link MultiLineString} in the reverse
102 * order to this object.
103 * Both the order of the component LineStrings
104 * and the order of their coordinate sequences
105 * are reversed.
106 *
107 * @return a {@link MultiLineString} in the reverse order
108 */
109 public Geometry reverse()
110 {
111 int nLines = geometries.length;
112 LineString[] revLines = new LineString[nLines];
113 for (int i = 0; i < geometries.length; i++) {
114 revLines[nLines - 1 - i] = (LineString)geometries[i].reverse();
115 }
116 return getFactory().createMultiLineString(revLines);
117 }
118
119 public boolean equalsExact(Geometry other, double tolerance) {
120 if (!isEquivalentClass(other)) {
121 return false;
122 }
123 return super.equalsExact(other, tolerance);
124 }
125
126}
127
Note: See TracBrowser for help on using the repository browser.