public class ShapefileWriter extends Object implements com.vividsolutions.jump.io.JUMPWriter
JUMPWriter specialized to write Shapefiles.
DataProperties for the ShapefileWriter write(DataProperties) interface:
| Parameter | Meaning |
|---|---|
| OutputFile or DefaultValue | File name for the output .shp file |
| ShapeType | Dimentionality of the Shapefile - 'xy', 'xym' or 'xyz'. 'xymz' and 'xyzm' are the same as 'xyz' |
NOTE: The input .dbf and .shx is assumed to be 'beside' (in the same directory) as the .shp file.
The shapefile writer consists of two parts: writing attributes (.dbf) and writing geometries (.shp).
JUMP columns are converted to DBF columns by:
| JUMP Column | DBF column |
|---|---|
| STRING | Type 'C' length is size of longest string in the FeatureCollection |
| DOUBLE | Type 'N' length is 33, with 16 digits right of the decimal |
| INTEGER | Type 'N' length is 16, with 0 digits right of the decimal |
For more information on the DBF file format, see the DBF Specification FAQ
Since shape files may contain only one type of geometry (POINT, MULTPOINT, POLYLINE, POLYGON, POINTM, MULTPOINTM, POLYLINEM, POLYGONM, POINTZ, MULTPOINTZ, POLYLINEZ, or POLYGONZ), the FeatureCollection must be first be normalized to one type:
| First non-NULL non-Point geometry in FeatureCollection | Coordinate Dimensionality | Shape Type |
|---|---|---|
| MULTIPOINT | xy xym xyzm | MULTIPOINT MULTIPOINTM MULTIPOINTZ |
| LINESTRING/MULTILINESTRING | xy xym xyzm | POLYLINE POLYLINEM POLYLINEZ |
| POLYGON/MULTIPOLYGON | xy xym xyzm | POLYGON POLYGONM POLYGONZ |
| All geometries in FeatureCollection are | Coordinate Dimensionality | Shape Type |
| POINT | xy xym xyzm | POINT POINTM POINTZ |
During this normalization process any non-consistent geometry will be replaced by a NULL geometry.
For example, if the shapetype is determined to be 'POLYLINE' any POINT, MULTIPOINT, or POLYGON geometries in the FeatureCollection will be replaced with a NULL geometry.
The coordinate dimensionality can be explicitly set with a DataProperties tag of 'ShapeType': 'xy', 'xym', or 'xyz' ('xymz' and 'xyzm' are pseudonyms for 'xyz'). If this DataProperties is unspecified, it will be auto set to 'xy' or 'xyz' based on the first non-NULL geometry having a Z coordinate.
Since JUMP and JTS do not currently support a M (measure) coordinate, it will always be set to �10E40 in the shape file (type 'xym' or 'xyzm'). This value represents the Measure "no data" value (page 2, ESRI Shapefile Technical Description). Since the 'NaN' DOUBLE values for Z coordinates is invalid in a shapefile, it is converted to '0.0'.
For more information on the shapefile format, see the ESRI Shapefile Spec
| Modifier and Type | Field and Description |
|---|---|
protected static com.vividsolutions.jts.algorithm.CGAlgorithms |
cga |
static String |
DEFAULT_VALUE_PROPERTY_KEY |
static String |
FILE_PROPERTY_KEY |
static String |
SHAPE_TYPE_PROPERTY_KEY |
static boolean |
truncate |
| Constructor and Description |
|---|
ShapefileWriter()
Creates new ShapefileWriter.
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkIfGeomsAreMixed(com.vividsolutions.jump.feature.FeatureCollection featureCollection)
DOCUMENT ME!
|
int |
guessCoordinateDims(com.vividsolutions.jts.geom.Geometry g)
Returns:
2 for 2d (default) 4 for 3d - one of the oordinates has a non-NaN z value (3 is for x,y,m but thats not supported yet) |
com.vividsolutions.jts.geom.GeometryCollection |
makePersistentSHAPEGeometryCollection(com.vividsolutions.jump.feature.FeatureCollection fc)
return a single geometry collection
result.GeometryN(i) = the i-th feature in the FeatureCollection All the geometry types will be the same type (ie. |
com.vividsolutions.jts.geom.GeometryCollection |
makeSHAPEGeometryCollection(com.vividsolutions.jump.feature.FeatureCollection fc)
return a single geometry collection
result.GeometryN(i) = the i-th feature in the FeatureCollection All the geometry types will be the same type (ie. |
void |
setRuleSet(WatergisDefaultRuleSet ruleSet,
Map<String,String> aliasNameToNameMap)
DOCUMENT ME!
|
void |
write(com.vividsolutions.jump.feature.FeatureCollection featureCollection,
com.vividsolutions.jump.io.DriverProperties dp)
Main method - write the featurecollection to a shapefile (2d, 3d or 4d).
|
void |
writePersistentFeatures(com.vividsolutions.jump.feature.FeatureCollection featureCollection,
com.vividsolutions.jump.io.DriverProperties dp)
Main method - write the featurecollection to a shapefile (2d, 3d or 4d).
|
public static final String FILE_PROPERTY_KEY
public static final String DEFAULT_VALUE_PROPERTY_KEY
public static final String SHAPE_TYPE_PROPERTY_KEY
public static boolean truncate
protected static com.vividsolutions.jts.algorithm.CGAlgorithms cga
public void write(com.vividsolutions.jump.feature.FeatureCollection featureCollection,
com.vividsolutions.jump.io.DriverProperties dp)
throws com.vividsolutions.jump.io.IllegalParametersException,
Exception
write in interface com.vividsolutions.jump.io.JUMPWriterfeatureCollection - collection to writedp - 'OutputFile' or 'DefaultValue' to specify where to write, and 'ShapeType' to specify
dimentionality.com.vividsolutions.jump.io.IllegalParametersException - DOCUMENT ME!Exception - DOCUMENT ME!public void setRuleSet(WatergisDefaultRuleSet ruleSet, Map<String,String> aliasNameToNameMap)
ruleSet - DOCUMENT ME!aliasNameToNameMap - DOCUMENT ME!public void writePersistentFeatures(com.vividsolutions.jump.feature.FeatureCollection featureCollection,
com.vividsolutions.jump.io.DriverProperties dp)
throws com.vividsolutions.jump.io.IllegalParametersException,
Exception,
InterruptedException
featureCollection - collection to writedp - 'OutputFile' or 'DefaultValue' to specify where to write, and 'ShapeType' to specify
dimentionality.com.vividsolutions.jump.io.IllegalParametersException - DOCUMENT ME!Exception - DOCUMENT ME!InterruptedException - DOCUMENT ME!public int guessCoordinateDims(com.vividsolutions.jts.geom.Geometry g)
g - geometry to test - looks at 1st coordinatepublic void checkIfGeomsAreMixed(com.vividsolutions.jump.feature.FeatureCollection featureCollection)
throws com.vividsolutions.jump.io.IllegalParametersException,
Exception
featureCollection - DOCUMENT ME!com.vividsolutions.jump.io.IllegalParametersException - DOCUMENT ME!Exception - DOCUMENT ME!public com.vividsolutions.jts.geom.GeometryCollection makeSHAPEGeometryCollection(com.vividsolutions.jump.feature.FeatureCollection fc)
throws Exception
fc - feature collection to make homogeneousException - DOCUMENT ME!public com.vividsolutions.jts.geom.GeometryCollection makePersistentSHAPEGeometryCollection(com.vividsolutions.jump.feature.FeatureCollection fc)
throws Exception
fc - feature collection to make homogeneousException - DOCUMENT ME!Copyright © 2012–2026 cismet GmbH. All rights reserved.