当前位置: 首页>>代码示例>>Java>>正文


Java WKTWriter.write方法代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:19,代码来源:OracleSqlDriver.java

示例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);
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:21,代码来源:JtsGeOxygene.java

示例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);
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:10,代码来源:ShapeSerializer.java

示例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);
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:10,代码来源:JGeometryField.java

示例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();
}
 
开发者ID:opentraffic,项目名称:traffic-example,代码行数:16,代码来源:App.java

示例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.");
    }
}
 
开发者ID:geoserver,项目名称:geofence,代码行数:13,代码来源:GeometryAdapter.java

示例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.");
    }
}
 
开发者ID:geoserver,项目名称:geofence,代码行数:13,代码来源:PolygonAdapter.java

示例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.");
    }
}
 
开发者ID:geoserver,项目名称:geofence,代码行数:13,代码来源:XMultiPolygonAdapter.java

示例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);
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:14,代码来源:BeanFeatureModel.java

示例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);
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:6,代码来源:GeometryUtils.java

示例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);
    }
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:7,代码来源:UnionCli.java

示例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');
}
 
开发者ID:reuven,项目名称:modelingcommons,代码行数:62,代码来源:MyWorld.java

示例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);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:55,代码来源:JTSFootprintParser.java

示例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;
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:16,代码来源:HsqlGeometryUserType.java

示例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);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:12,代码来源:Geometry.java


注:本文中的com.vividsolutions.jts.io.WKTWriter.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。