Skip to content

Commit 351b971

Browse files
authored
Fix image directory name and typos etc (#1162)
1 parent 9c9b9cd commit 351b971

File tree

13 files changed

+125
-80
lines changed

13 files changed

+125
-80
lines changed

doc/JTS Technical Specs.docx

-565 KB
Binary file not shown.

web/docs/developer/index.md

Lines changed: 86 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,38 @@ This document is intended for developers who would like to use JTS to accomplish
2525

2626
The most common JTS tasks involve creating and using Geometry objects. The easiest way to create a Geometry by hand is to use a WKTReader to generate one from a Well-Known Text (WKT) string. For example:
2727

28+
```java
2829
Geometry g1 = new WKTReader().read("LINESTRING (0 0, 10 10, 20 20)");
30+
```
2931

3032
A precise specification for WKT is given in the *JTS Technical Specifications*. And many examples of WKT may be found in the files in the *test* directory.
3133

3234
In a real program, it’s easier to use a GeometryFactory, because you don’t need to build up a WKT string; rather, you work with the objects directly:
3335

3436
```java
35-
Coordinate\[\] coordinates = new Coordinate\[\] {
36-
new Coordinate(0, 0), new Coordinate(10, 10),
37-
new Coordinate(20, 20\) };
38-
Geometry g1 = new GeometryFactory().createLineString(coordinates);
37+
Coordinate[] coordinates = new Coordinate[] {
38+
new Coordinate(0, 0), new Coordinate(10, 10), new Coordinate(20, 20) };
39+
Geometry g1 = new GeometryFactory().createLineString(coordinates);
3940
```
4041

4142
Once you’ve made your Geometry, there are many things you can do with it. You can easily find the intersection of two Geometries:
4243

44+
```java
4345
Geometry g3 = g1.intersection(g2);
46+
```
4447

45-
Other computations built into Geometries include: area, envelope, centroid, and buffer. For more information about what a Geometry can do, see the JavaDoc for Geometry in the com.vividsolutions.jts.geom package, as well as subsequent sections in this document.
48+
Other computations built into Geometries include: area, envelope, centroid, and buffer. For more information
49+
about what a Geometry can do, see the JavaDoc for Geometry in the `org.loctiontech.jts.geom`
50+
package, as well as subsequent sections in this document.
4651

4752
# **3. COMPUTING SPATIAL RELATIONSHIPS**
4853

4954
An important application of JTS is computing the spatial relationships between Geometries. Various methods of computing relationships are provided. JTS follows the **Dimensionally Extended 9 Intersection Matrix** model specified by the OGC. To compute the DE-9IM for two Geometries, use the relate method:
5055

5156
```java
52-
Geometry a = . . .
53-
Geometry b = . . .
54-
IntersectionMatrix m = a.relate(b);
57+
Geometry a = ...
58+
Geometry b = ...
59+
IntersectionMatrix m = a.relate(b);
5560
```
5661

5762
Most relationships of interest can be specified as a pattern which matches a set of intersection matrices. JTS also provides a set of boolean predicates which compute common spatial relationships directly. These are:
@@ -99,9 +104,18 @@ As with the spatial relationships described in the previous section, these overl
99104

100105
In GIS, buffering is an operation which in GIS is used to compute the area containing all points within a given distance of a Geometry. In mathematical terms, this is called computing the **Minkowski sum** of the Geometry with a disc of radius equal to the buffer distance. Finding positive and negative buffers is sometimes referred to as the operations of **erosion** and **dilation**. In CAD/CAM buffer curves are called **offset curves**.
101106

102-
You can use JTS to compute the **buffer** of a Geometry using the Geometry buffer method or the BufferOp class. The input Geometry to the buffer operation may be of any type (including arbitrary GeometryCollections). The result of a buffer operation is always an area type (Polygon or MultiPolygon). The result may be empty (for example, a negative buffer of a LineString).
107+
You can use JTS to compute the **buffer** of a Geometry using the
108+
Geometry buffer method or the `BufferOp` class. The input Geometry
109+
to the buffer operation may be of any type (including arbitrary
110+
`GeometryCollection`s). The result of a buffer operation is always an area
111+
type (`Polygon` or `MultiPolygon`). The result may be empty (for example,
112+
a negative buffer of a `LineString`).
103113

104-
You can compute buffers with both positive and negative buffer distances. Buffers with a positive buffer distance always contain the input Geometry. Buffers with a negative buffer distance are always contained within the input Geometry. A negative buffer of a LineString or a Point results in an empty Geometry.
114+
You can compute buffers with both positive and negative buffer
115+
distances. Buffers with a positive buffer distance always contain the
116+
input `Geometry`. Buffers with a negative buffer distance are always
117+
contained within the input `Geometry`. A negative buffer of a `LineString`
118+
or a `Point` results in an empty `Geometry`.
105119

106120
![](img/buffer.png) ![](img/negative_buffer.png)
107121

@@ -111,16 +125,19 @@ Buffer distances of 0 are also supported. You can use this to perform an efficie
111125

112126
## **5.1 BASIC BUFFERING**
113127

114-
To compute a buffer for a given distance, call the buffer() method on the Geometry:
128+
To compute a buffer for a given distance, call the `buffer()` method on the `Geometry`:
115129

116130
```java
117-
Geometry g = . . .
118-
Geometry buffer = g.buffer(100.0);
131+
Geometry g = ...
132+
Geometry buffer = g.buffer(100.0);
119133
```
120134

121135
## **5.2 END CAP STYLES**
122136

123-
Buffer polygons can be computed with different line **end cap styles**. The end cap style determines how the linework for the buffer polygon is constructed at the ends of linestrings. The following different kinds of end cap styles are supported:
137+
Buffer polygons can be computed with different line **end cap
138+
styles**. The end cap style determines how the line work for the buffer
139+
polygon is constructed at the ends of `lineString`s. The following
140+
different kinds of end cap styles are supported:
124141

125142
| *Style Name* | *Description* |
126143
| :---- | :---- |
@@ -136,26 +153,32 @@ The following diagrams illustrate the effects of specifying different end cap st
136153

137154
**Figure 5-2 \- Different End Cap Styles**
138155

139-
To specify the buffer end cap style, the BufferOp class in the package
156+
To specify the buffer end cap style, the `BufferOp` class in the package
140157

141-
com.vividsolutions.jts.operation.buffer is used directly:
158+
`org.locationtech.jts.operation.buffer` is used directly:
142159

143160
```java
144-
Geometry g = . . .
145-
BufferOp bufOp = new BufferOp(g);
146-
bufOp.setEndCapStyle(BufferOp.CAP_BUTT);
147-
Geometry buffer = bufOp.getResultGeometry(distance);
161+
Geometry g = ...
162+
BufferOp bufOp = new BufferOp(g);
163+
bufOp.setEndCapStyle(BufferOp.CAP_BUTT);
164+
Geometry buffer = bufOp.getResultGeometry(distance);
148165
```
149166

150167
## **5.3 SPECIFYING THE APPROXIMATION QUANTIZATION**
151168

152-
Since the exact buffer outline of a Geometry usually contains circular sections, the buffer must be approximated by the linear Geometry supported by JTS. The degree of approximation may be controlled by the user. In JTS this is done by specifying the number of quadrant segments used to approximate a quarter-circle. Specifying a larger number of segments results in a better approximation to the actual area, but also results in a larger number of line segments in the computed polygon.
169+
Since the exact buffer outline of a Geometry usually contains circular
170+
sections, the buffer must be approximated by the linear Geometry
171+
supported by JTS. The degree of approximation may be controlled by the
172+
user. In JTS this is done by specifying the number of quadrant segments
173+
used to approximate a quarter-circle. Specifying a larger number of
174+
segments results in a better approximation to the actual area, but also
175+
results in a larger number of line segments in the computed polygon.
153176

154177
To specify a value for the quadrant segments, use the Geometry buffer method with a second argument:
155178

156179
```java
157-
Geometry g = . . .
158-
Geometry buffer = g.buffer(100.0, 16);
180+
Geometry g = ...
181+
Geometry buffer = g.buffer(100.0, 16);
159182
```
160183

161184
The default number of segments is 8. This gives less than a 2% maximum error in the distance of the computed curve approximation to the actual buffer curve. This error can be reduced to less than 1% by using a value of 12. The diagram below shows the effect of increasing the number of approximation curve segments.
@@ -170,12 +193,16 @@ The default number of segments is 8. This gives less than a 2% maximum error in
170193

171194
Polygonization is the process of forming polygons from linework which encloses areas. Linework to be formed into polygons must be fully noded – that is, linestrings must not cross and must touch only at endpoints.
172195

173-
JTS provides the Polygonizer class to perform Polygonization. The Polygonizer takes a set of fully noded LineStrings and forms all the polygons which are enclosed by the lines. Polygonization errors such as dangling lines or cut lines can be identified and reported.
196+
JTS provides the `Polygonizer` class to perform polygonization. The `Polygonizer` takes a set of fully noded
197+
LineStrings and forms all the polygons which are enclosed by the lines. Polygonization errors such as
198+
dangling lines or cut lines can be identified and reported.
174199

175200
```java
176201
Collection lines = new ArrayList();
177202

178-
lines.add(read("LINESTRING (0 0 , 10 10)")); // isolated edge lines.add(read("LINESTRING (185 221, 100 100)")); //dangling edge lines.add(read("LINESTRING (185 221, 88 275, 180 316)"));
203+
lines.add(read("LINESTRING (0 0 , 10 10)"));
204+
// isolated edge lines.add(read("LINESTRING (185 221, 100 100)"));
205+
//dangling edge lines.add(read("LINESTRING (185 221, 88 275, 180 316)"));
179206

180207
lines.add(read("LINESTRING (185 221, 292 281, 180 316)"));
181208
lines.add(read("LINESTRING (189 98, 83 187, 185 221)"));
@@ -205,11 +232,17 @@ Sometimes a spatial operation such as \#union will produce chains of small LineS
205232

206233
**Figure 7-1 – The Line-Merging Operation**
207234

208-
The LineMerger assumes that the input LineStrings are *noded* (i.e. they do not cross; only their endpoints can touch. See *9.1 Noding A Set Of LineStrings* on page 11). Note that the output LineStrings are also noded.
235+
The `LineMerger` assumes that the input `LineStrings` are *noded* (i.e. they do not cross; only their
209236

210-
If LineStrings to be merged do not have the same direction, the direction of the resulting LineString will be that of the majority.
237+
**TODO** fix this link
211238

212-
The LineMerger is used as follows:
239+
endpoints can touch. See *9.1 Noding A Set Of `LineStrings`* on page 11). Note that the output `LineStrings`
240+
are also noded.
241+
242+
If `LineStrings` to be merged do not have the same direction, the direction of the resulting `LineString`
243+
will be that of the majority.
244+
245+
The `LineMerger` is used as follows:
213246

214247
```java
215248
LineMerger lineMerger = new LineMerger();
@@ -222,35 +255,43 @@ Collection mergedLineStrings = lineMerger.getMergedLineStrings();
222255

223256
By default JTS uses arrays of Coordinates to represent the points and lines of Geometries. There are some cases in which you might want Geometries to store their points using some other implementation. For example, to save memory you may want to use a more compact sequence implementation, such as an array of x’s and an array of y’s. Another possibility is to use a custom coordinate class to store extra information on each coordinate, such as measures for linear referencing.
224257

225-
You can do this by implementing the CoordinateSequence and
226-
227-
CoordinateSequenceFactory interfaces. You would then create a GeometryFactory parameterized by your CoordinateSequenceFactory, and use this GeometryFactory to create new Geometries. All of these new Geometries will use your CoordinateSequence implementation.
258+
You can do this by implementing the `CoordinateSequence` and
259+
`CoordinateSequenceFactory` interfaces. You would then create a `GeometryFactory` parameterized by your
260+
`CoordinateSequenceFactory`, and use this `GeometryFactory` to create new `Geometries`. All of these new
261+
`Geometries` will use your `CoordinateSequence` implementation.
228262

229263
For an example, see the following sample programs in the
230264

231-
com.vividsolutions.jtsexample.geom package:
265+
org.locationtech.jtsexample.geom package:
232266

233267
| ExtendedCoordinateExample | An example of using adding information to the basic coordinate representation |
234268
| :---- | :---- |
235269
| TwoArrayCoordinateSequenceExample | An example of using a more memory-efficient sequence implementation |
236270

237-
A note on performance: If your CoordinateSequence is not based on an array of the standard JTS Coordinates (or a subclass of Coordinate), it may incur a small performance penalty. This is due to the marshalling and unmarshalling required for JTS to convert the user coordinates into arrays of JTS coordinates.
271+
A note on performance: If your `CoordinateSequence` is not based on an array of the standard JTS
272+
`Coordinates` (or a subclass of Coordinate), it may incur a small performance penalty. This is due to the
273+
marshalling and unmarshalling required for JTS to convert the user coordinates into arrays of JTS
274+
coordinates.
238275

239276
# **9. TIPS & TECHNIQUES**
240277

241278
## **9.1 NODING A SET OF LINESTRINGS**
242279

243-
Many spatial operations assume that their input data is **noded**, meaning that LineStrings never cross. For example, the JTS Polygonizer and the JTS LineMerger described earlier assume that their input is noded.
280+
Many spatial operations assume that their input data is **noded**, meaning that `LineStrings` never cross. For
281+
example, the JTS `Polygonizer` and the JTS `LineMerger` described earlier assume that their input is noded.
244282

245-
The noding process splits LineStrings that cross into smaller LineStrings that meet at a point, or **node**, as illustrated below.
283+
The noding process splits `LineStrings` that cross into smaller `LineStrings` that meet at a point, or
284+
**node**, as illustrated below.
246285

247286
| ![](img/noded_3.png) | ![](img/noded_9.png) |
248287
| :---: | :---: |
249288
| ***Not noded (3 LineStrings)*** | ***Noded (9 LineStrings)*** |
250289

251290
**Figure 9-1 – Before and After Noding**
252291

253-
A simple trick for noding a group of LineStrings is to union them together. It turns out that the unioning process will node the LineStrings for us. For example, the following code will node a collection of LineStrings:
292+
A simple trick for noding a group of `LineStrings` is to union them together. It turns out that the unioning
293+
process will node the `LineStrings` for us. For example, the following code will node a collection of
294+
`LineStrings`:
254295

255296
```java
256297
Collection lineStrings = . . .
@@ -262,11 +303,14 @@ for (int i = 1; i \< lineStrings.size(); i++) {
262303

263304
# **10. UNIONING MANY POLYGONS EFFICIENTLY**
264305

265-
Calling Polygon\#union repeatedly is one way to union several Polygons together. But here’s a trick that can be significantly faster (seconds rather than minutes) – add the Polygons to a GeometryCollection, then apply a buffer with zero distance:
306+
Calling `Polygon.union` repeatedly is one way to union several `Polygons`
307+
together. But here’s a trick that can be significantly faster (seconds
308+
rather than minutes) – add the `Polygons` to a `GeometryCollection`,
309+
then apply a buffer with zero distance:
266310

267311
```java
268-
Polygon\[\] polygons = . . .
269-
GeometryCollection polygonCollection =
270-
geometryFactory.createGeometryCollection(polygons);
271-
Geometry union = polygonCollection.buffer(0);
272-
```
312+
Polygon[] polygons = ...
313+
GeometryCollection polygonCollection =
314+
geometryFactory.createGeometryCollection(polygons);
315+
Geometry union = polygonCollection.buffer(0);
316+
```

0 commit comments

Comments
 (0)