| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
package org.locationtech.jts.geom.prep; |
| 13 |
|
| 14 |
import org.locationtech.jts.geom.Geometry; |
| 15 |
import org.locationtech.jts.geom.Lineal; |
| 16 |
import org.locationtech.jts.geom.Polygonal; |
| 17 |
import org.locationtech.jts.geom.Puntal; |
| 18 |
|
| 19 |
/** |
| 20 |
* A factory for creating {@link PreparedGeometry}s. |
| 21 |
* It chooses an appropriate implementation of PreparedGeometry |
| 22 |
* based on the geometric type of the input geometry. |
| 23 |
* <p> |
| 24 |
* In the future, the factory may accept hints that indicate |
| 25 |
* special optimizations which can be performed. |
| 26 |
* <p> |
| 27 |
* Instances of this class are thread-safe. |
| 28 |
* |
| 29 |
* @author Martin Davis |
| 30 |
* |
| 31 |
*/ |
| 32 |
public class PreparedGeometryFactory |
| 33 |
{ |
| 34 |
/** |
| 35 |
* Creates a new {@link PreparedGeometry} appropriate for the argument {@link Geometry}. |
| 36 |
* |
| 37 |
* @param geom the geometry to prepare |
| 38 |
* @return the prepared geometry |
| 39 |
*/ |
| 40 |
public static PreparedGeometry prepare(Geometry geom) |
| 41 |
{ |
| 42 |
return (new PreparedGeometryFactory()).create(geom); |
| 43 |
} |
| 44 |
|
| 45 |
public PreparedGeometryFactory() { |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Creates a new {@link PreparedGeometry} appropriate for the argument {@link Geometry}. |
| 50 |
* |
| 51 |
* @param geom the geometry to prepare |
| 52 |
* @return the prepared geometry |
| 53 |
*/ |
| 54 |
public PreparedGeometry create(Geometry geom) |
| 55 |
{ |
| 56 |
if (geom instanceof Polygonal) |
| 57 |
return new PreparedPolygon((Polygonal) geom); |
| 58 |
if (geom instanceof Lineal) |
| 59 |
return new PreparedLineString((Lineal) geom); |
| 60 |
if (geom instanceof Puntal) |
| 61 |
return new PreparedPoint((Puntal) geom); |
| 62 |
|
| 63 |
/** |
| 64 |
* Default representation. |
| 65 |
*/ |
| 66 |
return new BasicPreparedGeometry(geom); |
| 67 |
} |
| 68 |
} |
| 69 |
|