本文整理汇总了Java中com.vividsolutions.jts.io.WKTWriter.write方法的典型用法代码示例。如果您正苦于以下问题:Java WKTWriter.write方法的具体用法?Java WKTWriter.write怎么用?Java WKTWriter.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vividsolutions.jts.io.WKTWriter
的用法示例。
在下文中一共展示了WKTWriter.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readGeometry
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
@Override
public String readGeometry(Wrapper aRs, int aColumnIndex, Connection aConnection) throws SQLException {
Object read = aRs instanceof ResultSet ? ((ResultSet) aRs).getObject(aColumnIndex) : ((CallableStatement) aRs).getObject(aColumnIndex);
boolean wasNull = aRs instanceof ResultSet ? ((ResultSet) aRs).wasNull() : ((CallableStatement) aRs).wasNull();
if (wasNull) {
return null;
} else {
if (read instanceof STRUCT) {
STRUCT struct = (STRUCT) read;
GeometryConverter reader = new GeometryConverter(struct.getInternalConnection());
Geometry geometry = reader.asGeometry(struct);
WKTWriter writer = new WKTWriter();
return writer.write(geometry);
} else {
return null;
}
}
}
示例2: makeGeOxygeneGeom
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
/**
* Conversion d'une géométrie JTS {@link Geometry} en géométrie GeOxygene
* {@link IGeometry}.
* @param adapter si adapter est vrai, on utiliser la factory
* {@link AdapterFactory}, sinon, on passe par WKT
* @param jtsGeom une géométrie JTS
* @return une géométrie GeOxygene équivalente
* @throws Exception Exception renvoie une exception si la géométrie en entrée
* n'est pas valide
*/
public static IGeometry makeGeOxygeneGeom(Geometry jtsGeom, boolean adapter)
throws Exception {
if (adapter) {
return AdapterFactory.toGM_Object(jtsGeom);
}
WKTWriter jtsWktWriter = new WKTWriter();
String wktResult = jtsWktWriter.write(jtsGeom);
return WktGeOxygene.makeGeOxygene(wktResult);
}
示例3: serialize
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
@Override
public void serialize(Geometry value, JsonGenerator jgen,
SerializerProvider provider) throws IOException,
JsonProcessingException {
WKTWriter shapeWriter = new WKTWriter();
String wkt = shapeWriter.write(value);
jgen.writeString(wkt);
}
示例4: setValue
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
@Override
public void setValue(final Object value) {
final Geometry geom = (Geometry) value;
final WKTWriter writer = new WKTWriter(getD());
final String wkt = writer.write(geom);
text.setText(wkt);
}
示例5: outputTriplines
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
private static void outputTriplines(TrafficEngine te, String fnout) throws FileNotFoundException {
WKTWriter writer = new WKTWriter();
PrintWriter printWriter = new PrintWriter (fnout);
printWriter.println( "wayid,clusterid,geom" );
List<TripLine> triplines = te.getTripLines();
for( TripLine tl : triplines ){
LineString ls = tl.getGeom();
String wkt = writer.write(ls);
printWriter.println( String.format("%s,%s,\"%s\"", tl.getWayId(), tl.getClusterIndex(), wkt) );
}
printWriter.close();
}
示例6: marshal
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
@Override
public String marshal(G the_geom) throws ParseException {
if (the_geom != null) {
WKTWriter wktWriter = new WKTWriter();
if (the_geom.getSRID() == 0)
the_geom.setSRID(4326);
return wktWriter.write(the_geom);
} else {
throw new ParseException("Geometry obj is null.");
}
}
示例7: marshal
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
@Override
public String marshal(Polygon the_geom) throws ParseException {
if (the_geom != null) {
WKTWriter wktWriter = new WKTWriter();
if (the_geom.getSRID() == 0)
the_geom.setSRID(4326);
return wktWriter.write(the_geom);
} else {
throw new ParseException("Polygon obj is null.");
}
}
示例8: marshal
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
@Override
public String marshal(MultiPolygon the_geom) throws ParseException {
if (the_geom != null) {
WKTWriter wktWriter = new WKTWriter();
if (the_geom.getSRID() == 0)
the_geom.setSRID(4326);
return wktWriter.write(the_geom);
} else {
throw new ParseException("Geometry obj is null.");
}
}
示例9: setGeometry
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
public void setGeometry(Object feature, Geometry geometry) throws LayerException {
Entity entity = entityMapper.asEntity(feature);
if (wkt) {
WKTWriter writer = new WKTWriter();
String wktStr = null;
if (null != geometry) {
wktStr = writer.write(geometry);
}
entity.setAttribute(getGeometryAttributeName(), wktStr);
} else {
entity.setAttribute(getGeometryAttributeName(), geometry);
}
}
示例10: createRectangleWithSideLengthInMetersAsWkt
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
public static String createRectangleWithSideLengthInMetersAsWkt(Point p, double sideLengthMeters) {
Polygon poly = createRectangleWithSideLengthInMeters(p, sideLengthMeters);
WKTWriter wktWriter = new WKTWriter();
return wktWriter.write(poly);
}
示例11: writeGeometries
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
private static void writeGeometries(final Geometry geom, final String fileName) throws IOException {
try (final Writer writer = new FileWriter(new File(fileName))) {
final WKTWriter wkbWriter = new WKTWriter(2);
wkbWriter.write(geom, writer);
}
}
示例12: writeVectorDataset
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
/** */
private static void writeVectorDataset (VectorDataset dataset, Writer out)
throws IOException {
out.write("VECTOR\n");
if (GISExtension.getState().getProjection() != null) {
out.write(PROJ_FORMAT.format(GISExtension.getState().getProjection()));
}
out.write('\n');
switch (StoreDataset.esriShapeType(dataset)) {
case ESRIShapefileWriter.SHAPE_TYPE_POINT:
out.write("POINT");
break;
case ESRIShapefileWriter.SHAPE_TYPE_MULTIPOINT:
out.write("MULTIPOINT");
break;
case ESRIShapefileWriter.SHAPE_TYPE_POLYLINE:
out.write("POLYLINE");
break;
case ESRIShapefileWriter.SHAPE_TYPE_POLYGON:
out.write("POLYGON");
break;
default:
out.write("NULL");
break;
}
out.write('\n');
VectorDataset.Property[] properties = dataset.getProperties();
for (int i = 0; i < properties.length; i += 1) {
if (i > 0) {
out.write(' ');
}
StringUtils.writeDelimited(properties[i].getName(), ' ', out);
}
out.write('\n');
for (int i = 0; i < properties.length; i += 1) {
if (i > 0) {
out.write(' ');
}
out.write(properties[i].getType().name());
}
out.write('\n');
WKTWriter gOut = new WKTWriter();
for (Iterator<VectorFeature> i = dataset.getFeatures().iterator(); i.hasNext(); ) {
VectorFeature feature = i.next();
// write record
for (int j = 0; j < properties.length; j += 1) {
Object datum = feature.getProperty(properties[j].getName());
String value = (datum != null) ? datum.toString() : "";
if (j > 0) {
out.write(' ');
}
StringUtils.writeDelimited(value, ' ', out);
}
out.write('\n');
// write geometry
gOut.write(feature.getGeometry(), out);
out.write('\n');
}
out.write('\n');
out.write('\n');
}
示例13: cutOnPoles
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
/**
* Cut given polygon on poles (89 and -89)
*/
private static String cutOnPoles(String polygonWKT) throws Exception
{
JtsSpatialContextFactory noCheckFactory = new JtsSpatialContextFactory();
noCheckFactory.datelineRule = DatelineRule.none;
noCheckFactory.validationRule = ValidationRule.none;
JtsSpatialContext noCheckContext = noCheckFactory.newSpatialContext();
JtsWKTReaderShapeParser noCheckParser =
new JtsWKTReaderShapeParser(noCheckContext, noCheckFactory);
JtsGeometry polygon = (JtsGeometry) noCheckParser.parse(polygonWKT);
JtsGeometry northPole =
(JtsGeometry) noCheckParser.parse("LINESTRING(180 89, 0 89, -180 89)");
JtsGeometry southPole =
(JtsGeometry) noCheckParser.parse("LINESTRING(180 -89, 0 -89, -180 -89)");
LineMerger lm = new LineMerger();
lm.add(polygon.getGeom());
lm.add(northPole.getGeom());
lm.add(southPole.getGeom());
Geometry geometry = UnaryUnionOp.union(lm.getMergedLineStrings());
Polygonizer polygonizer = new Polygonizer();
polygonizer.add(geometry);
List<Polygon> foundPolygons = (List<Polygon>) polygonizer.getPolygons();
List<Polygon> filteredPolygons = new ArrayList<>();
for (Polygon p: foundPolygons)
{
// removing polygons over the poles
if (p.getCentroid().getCoordinate().y < 89 && p.getCentroid().getCoordinate().y > -89)
{
filteredPolygons.add(p);
}
}
Geometry res = null;
if (!filteredPolygons.isEmpty())
{
res = filteredPolygons.get(0);
}
if (filteredPolygons.size() > 1)
{
// Should not happen...
LOGGER.error("A Multipolygon was found, instead of a single polygon. Only the first one is retained.");
}
WKTWriter wkw = new WKTWriter();
return wkw.write(res);
}
示例14: conv2DBGeometry
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
/**
* Converts a JTS <code>Geometry</code> to a native geometry object.
*
* @param jtsGeom
* JTS Geometry to convert
* @param connection
* the current database connection
* @return native database geometry object corresponding to jtsGeom.
*/
public Object conv2DBGeometry(Geometry jtsGeom, Connection connection) {
int srid = jtsGeom.getSRID();
WKTWriter writer = new WKTWriter();
String wkt = writer.write(jtsGeom);
return srid + "|" + wkt;
}
示例15: toText
import com.vividsolutions.jts.io.WKTWriter; //导入方法依赖的package包/类
/**
* Returns the Well-known Text representation of this <code>Geometry</code>.
* For a definition of the Well-known Text format, see the OpenGIS Simple
* Features Specification.
*
* @return the Well-known Text representation of this <code>Geometry</code>
*/
public String toText() {
WKTWriter writer = new WKTWriter();
return writer.write(this);
}