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


Java WKTReader.read方法代码示例

本文整理汇总了Java中com.vividsolutions.jts.io.WKTReader.read方法的典型用法代码示例。如果您正苦于以下问题:Java WKTReader.read方法的具体用法?Java WKTReader.read怎么用?Java WKTReader.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vividsolutions.jts.io.WKTReader的用法示例。


在下文中一共展示了WKTReader.read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tryCatalog

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
private void tryCatalog() throws Exception {
    Connection conn = DriverManager.getConnection("jdbc:h2:~/.sumo/SUMO_DB;AUTO_SERVER=TRUE", "sa", "");
    Statement stat = conn.createStatement();
    List<File> readFiles = new ArrayList<File>();

    String sql = "SELECT * FROM CATALOGUE";
    ResultSet res = stat.executeQuery(sql);
    Geometry imageGeom = null;
    WKTReader wktr = new WKTReader();
    while (res.next()) {
        imageGeom = wktr.read(res.getString("GEOM"));
        String fileName = res.getString("IMAGENAME");
        File f = new File(fileName);
        readFiles.add(f);
    }
    jList1.removeAll();
    jList1.setListData(readFiles.toArray());
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:19,代码来源:BatchAnalysisGUI.java

示例2: doSelect

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
private void doSelect() {
    if (whereClause != null) {
        try {
            Connection conn = DriverManager.getConnection("jdbc:h2:~/.sumo/VectorData;AUTO_SERVER=TRUE", "sa", "");
            Statement stat = conn.createStatement();
            ResultSet rs = stat.executeQuery("SELECT * FROM \"" + glayer.getName() + "\" WHERE " + whereClause);
            WKTReader wkt = new WKTReader();
            String[] schema = glayer.getSchema();
            //TODO:schema type problem check!!
            //String[] types = glayer.getSchemaTypes();
            glayer.clear();
            while (rs.next()) {
                Geometry geom = wkt.read(rs.getString("geom"));
                AttributesGeometry att = new AttributesGeometry(schema);
                for (String key : schema) {
                    att.set(key, rs.getString(key));
                }
                glayer.put(geom, att);
            }
        } catch (Exception ex) {
            logger.error(ex.getMessage(),ex);
        }
        whereClause = null;
    }
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:26,代码来源:SelectableVectorLayer.java

示例3: checkJTSFootprint

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
/**
 * Check JTS Footprint validity
 */
public static boolean checkJTSFootprint (String footprint)
{
   try
   {
      WKTReader wkt = new WKTReader();
      Geometry geom = wkt.read(footprint);
      IsValidOp vaildOp = new IsValidOp(geom);
      TopologyValidationError err = vaildOp.getValidationError();
      if (err != null)
      {
         throw new IllegalParameterException(err.getMessage());
      }
      return true;
   }
   catch (Exception e)
   {
      LOGGER.error("JTS Footprint error : " + e.getMessage());
      return false;
   }
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:24,代码来源:ProcessingUtils.java

示例4: testCompileArcWithTolerance

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
@Test
public void testCompileArcWithTolerance() {
  WKTReader reader = new WKTReader();
  try {
    Geometry g1 = reader
        .read("LINESTRING (601103.3340069023 129288.05055561525, 601102.0842804064 129856.67611130093, 601320.7864172085 129316.79426502353, 601323.263544294 129847.90736367383)");
    Geometry g2 = reader
        .read("LINESTRING (601323.2858702005 129847.92802582885, 601824.4261951016 129860.42529078897, 601968.144742143 129494.25542745732, 601806.9300241574 129236.81176927875, 601447.0087933057 129430.51937616068, 601422.0142633856 129672.9663163871, 601549.4863659788 129830.43185488468)");

    ILineString line1 = (ILineString) AdapterFactory.toGM_Object(g1);
    ILineString line2 = (ILineString) AdapterFactory.toGM_Object(g2);
    List<ILineString> list = new ArrayList<ILineString>();
    list.add(line1);
    list.add(line2);
    ILineString result = Operateurs.compileArcs(list, 1.0);
    Assert.assertNotNull(result);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:21,代码来源:OperateursTest.java

示例5: testUnionWithTolerance

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
@Test
public void testUnionWithTolerance() {
  WKTReader reader = new WKTReader();
  try {
    Geometry g1 = reader
        .read("LINESTRING (601103.3340069023 129288.05055561525, 601102.0842804064 129856.67611130093, 601320.7864172085 129316.79426502353, 601323.263544294 129847.90736367383)");
    Geometry g2 = reader
        .read("LINESTRING (601323.2858702005 129847.92802582885, 601824.4261951016 129860.42529078897, 601968.144742143 129494.25542745732, 601806.9300241574 129236.81176927875, 601447.0087933057 129430.51937616068, 601422.0142633856 129672.9663163871, 601549.4863659788 129830.43185488468)");

    ILineString line1 = (ILineString) AdapterFactory.toGM_Object(g1);
    ILineString line2 = (ILineString) AdapterFactory.toGM_Object(g2);
    List<ILineString> list = new ArrayList<ILineString>();
    list.add(line1);
    list.add(line2);
    ILineString result = Operateurs.union(list, 1.0);
    if (result.equals(line1)) {
      Assert.fail();
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:23,代码来源:OperateursTest.java

示例6: getSimilarity

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
@Override
public double getSimilarity(Object object1, Object object2) {
    // expects WKT Strings
    String sWKT, tWKT;
    Geometry sGeo, tGeo;
    sWKT = object1.toString();
    tWKT = object2.toString();
    WKTReader reader = new WKTReader();
    try {
        sGeo = reader.read(sWKT);
        tGeo = reader.read(tWKT);
    } catch (ParseException e) {
        e.printStackTrace();
        return 0d;
    }
    return sGeo.contains(tGeo) ? 1d : 0d;
}
 
开发者ID:dice-group,项目名称:LIMES,代码行数:18,代码来源:ContainsMeasure.java

示例7: getSimilarity

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
@Override
public double getSimilarity(Object object1, Object object2) {
    // expects WKT Strings
    String sWKT, tWKT;
    Geometry sGeo, tGeo;
    sWKT = object1.toString();
    tWKT = object2.toString();
    WKTReader reader = new WKTReader();
    try {
        sGeo = reader.read(sWKT);
        tGeo = reader.read(tWKT);
    } catch (ParseException e) {
        e.printStackTrace();
        return 0d;
    }
    return sGeo.touches(tGeo) ? 1d : 0d;
}
 
开发者ID:dice-group,项目名称:LIMES,代码行数:18,代码来源:TouchesMeasure.java

示例8: populatePolygons

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
private void populatePolygons(List<String> coordinateHNodeIds,
		ArrayList<Row> rows, Map<String, String> columnNameMap) {
	for (Row row : rows) {
		try {
			String posList = row.getNode(coordinateHNodeIds.get(0))
					.getValue().asString();
	        WKTReader reader = new WKTReader();
	        Polygon JTSPolygon = (Polygon)reader.read(posList);
	        if(JTSPolygon == null) continue;
	        polygons.add(JTSPolygon);
			FeatureTable featureTable = new FeatureTable();
			Collection<Node> nodes = row.getNodes();
			for (Node node : nodes) {
				if (!(coordinateHNodeIds.contains(node.getHNodeId()))
						&& !(node.hasNestedTable())) {
					featureTable.addColumnToDescription(columnNameMap.get(node
							.getHNodeId()), node.getValue().asString());
				}
			}
			polygonTable.add(featureTable);
		} catch (Exception e) {
			logger.error("Error creating line! Skipping it.", e);
			continue;
		}
	}
}
 
开发者ID:therelaxist,项目名称:spring-usc,代码行数:27,代码来源:WorksheetGeospatialContent.java

示例9: getSimilarity

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
@Override
public double getSimilarity(Object object1, Object object2) {
    // expects WKT Strings
    String sWKT, tWKT;
    Geometry sGeo, tGeo;
    sWKT = object1.toString();
    tWKT = object2.toString();
    WKTReader reader = new WKTReader();
    try {
        sGeo = reader.read(sWKT);
        tGeo = reader.read(tWKT);
    } catch (ParseException e) {
        e.printStackTrace();
        return 0d;
    }
    return sGeo.overlaps(tGeo) ? 1d : 0d;
}
 
开发者ID:dice-group,项目名称:LIMES,代码行数:18,代码来源:OverlapsMeasure.java

示例10: getSimilarity

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
@Override
public double getSimilarity(Object object1, Object object2) {
    // expects WKT Strings
    String sWKT, tWKT;
    Geometry sGeo, tGeo;
    sWKT = object1.toString();
    tWKT = object2.toString();
    WKTReader reader = new WKTReader();
    try {
        sGeo = reader.read(sWKT);
        tGeo = reader.read(tWKT);
    } catch (ParseException e) {
        e.printStackTrace();
        return 0d;
    }
    return sGeo.coveredBy(tGeo) ? 1d : 0d;
}
 
开发者ID:dice-group,项目名称:LIMES,代码行数:18,代码来源:CoveredbyMeasure.java

示例11: getInstanceOfCountry

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
public static SimpleFeature getInstanceOfCountry() throws Exception {

        if (COUNTRY != null) {
            return COUNTRY;
        }
        final SimpleFeatureType type = DataUtilities.createType("Location",
                "geometry:Polygon:srid=4326," + "countryName:String," + "population:Integer,"
                        + "principalMineralResource:String");
        SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(type);

        WKTReader reader = new WKTReader();
        MultiPolygon geometry = (MultiPolygon) reader.read(usaGeometry());

        featureBuilder.add(geometry);
        featureBuilder.add("USA");
        featureBuilder.add(307006550);
        featureBuilder.add("oil");

        COUNTRY = featureBuilder.buildFeature(null);

        return COUNTRY;
    }
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:23,代码来源:DataExamples.java

示例12: getPositionFromSamplingPoint

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
/**
 * Parse the position from a given {@link SamplingPointType}
 * @throws com.vividsolutions.jts.io.ParseException 
 */
private Geometry getPositionFromSamplingPoint(SamplingPointType spt) throws com.vividsolutions.jts.io.ParseException {
	if (spt.getPosition().isSetPoint()) {
		PointType point = spt.getPosition().getPoint();

		if (point.isSetPos()) {
			WKTReader reader = new WKTReader();
			return reader.read("POINT("+ point.getPos().getStringValue() + ")");
		}
	}

	else if (spt.isSetBoundedBy()) {
		BoundingShapeType bb = spt.getBoundedBy();
		EnvelopeType env = bb.getEnvelope();
		return getGeometryFromEnvelope(env);
	}

	return null;
}
 
开发者ID:52North,项目名称:epos,代码行数:23,代码来源:OMParser.java

示例13: create

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
@Test
public void create() throws ParseException, LayerException {
	Object created = null;
	WKTReader wktReader = new WKTReader();
	Point geometry = null;
	geometry = (Point) wktReader.read("POINT (0 0)");

	Object feature = (SimpleFeature)layer.getFeatureModel().newInstance("500");
	Map<String, Attribute> map = new HashMap<String, Attribute>();
	map.put("NAME", new StringAttribute("Tsjakamaka"));
	map.put("POP_OTHER", new IntegerAttribute(342));
	layer.getFeatureModel().setAttributes(feature, map);
	layer.getFeatureModel().setGeometry(feature, geometry);
	
	created = layer.create(feature);
	Assert.assertNotNull(created);
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:18,代码来源:ShapeInMemLayerTest.java

示例14: extractGeometry

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
private static Geometry extractGeometry(Object g0) {
	if (g0 instanceof Geometry) {
		//geometry given -> cast
		return (Geometry) g0;
	}
	else {
		//parse string
		WKTReader r = new WKTReader();
		try {
			return r.read(g0.toString());
		}
		catch (ParseException e) {
			logger.warn(e.getMessage(), e);
		}
	}
	return null;
}
 
开发者ID:52North,项目名称:SES,代码行数:18,代码来源:SpatialMethods.java

示例15: getUserDtoFromEntity

import com.vividsolutions.jts.io.WKTReader; //导入方法依赖的package包/类
/**
 * Map user entity into data transfer object
 * 
 * @param user User Entity
 * @return UserDTO
 */
public UserDTO getUserDtoFromEntity(User user){
	//convert geometry object to a point
	Geometry g = null;
	com.vividsolutions.jts.geom.Point point = null;		
	WKTReader reader = new WKTReader();
	try {
		g = reader.read(user.getLocation().toText());
		point = (com.vividsolutions.jts.geom.Point) g;
	}
	catch (Exception e) {
		//do nothing
	}
	//start mapping data into the dto
	if (user == null)
		return null;
	
	UserDTO userDTO = map(user, UserDTO.class);
	//add mapping for location if point object is not null
	if (point != null) {
		org.springframework.data.geo.Point gp = new Point(point.getX(), point.getY());
		userDTO.setLongitude(Double.toString(point.getX()));
		userDTO.setLatitude(Double.toString(point.getY()));
	}
	userDTO.setDisplayFlag((user.getDisplayFlag() != null && user.getDisplayFlag().booleanValue()) ? "Y" : "N");
	return userDTO;
}
 
开发者ID:Code4SocialGood,项目名称:C4SG-Obsolete,代码行数:33,代码来源:UserMapper.java


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