當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。