精华内容
下载资源
问答
  • 由shp文件生成geojson

    千次阅读 2017-04-11 14:02:42
    一、读取shp文件内容 并 据此 生成FeatureJson public static List readShp(String path){ ShapefileDataStore shpDataStore = null; List list = new ArrayList(); try{ shpDataStore = new ...

    一、读取shp文件内容 并 据此 生成FeatureJson

    public static List readShp(String path){
    		ShapefileDataStore shpDataStore = null;  
    		List list = new ArrayList();
    	    try{  
    	        shpDataStore = new ShapefileDataStore(new File(path).toURI().toURL());  
    	        shpDataStore.setCharset(Charset.forName("GBK"));  
    	        String typeName = shpDataStore.getTypeNames()[0];  
    	        FeatureSource featureSource = null;   
    	        featureSource = shpDataStore.getFeatureSource(typeName);  
    	        FeatureCollection result = featureSource.getFeatures();  
    	        geneGeoJson(result);
    	    } catch (MalformedURLException e) {  
    	        e.printStackTrace();  
    	    } catch(IOException e) { e.printStackTrace(); }  
            return list;
    	}  
    public static void geneGeoJson(FeatureCollection fc) throws IOException{
    		FeatureJSON fjson = new FeatureJSON(new GeometryJSON(13));//13代表生成的几何类型的参数的保留小数位是13位,不写默认4位
    		//StringWriter writer = new StringWriter();
    		fjson.writeFeatureCollection(fc, "WebRoot/geojson/point.geojson");
    		//String json = writer.toString();
    		//System.out.println(json);
    
    	}
    二、由单个Feature生成的geojson

    public static String getJson(SimpleFeature feature) throws IOException{
    		FeatureJSON fjson = new FeatureJSON();
    		StringWriter writer = new StringWriter();
    		fjson.writeFeature(feature,writer);
    		String json = writer.toString();
    		return json;
    	}
    





    展开全文
  • 测试

    2019-08-02 17:48:00
    aaa GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();WKTReader reader = new WKTReader(geometryFactory);Geometry geom = reader.read("Point(1 1)");FeatureJSON featureJSON = ...

    aaa

    GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
    WKTReader reader = new WKTReader(geometryFactory);
    Geometry geom = reader.read("Point(1 1)");

    FeatureJSON featureJSON = new FeatureJSON();

    GeometryJSON json = new GeometryJSON(6);
    StringWriter writer = new StringWriter();
    json.write(geom, writer);
            GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
            WKTReader reader = new WKTReader(geometryFactory);
            Geometry geom = reader.read("Point(1 1)");
    
            FeatureJSON featureJSON = new FeatureJSON();
            
            GeometryJSON json = new GeometryJSON(6);
            StringWriter writer = new StringWriter();
            json.write(geom, writer);
            System.out.println(writer.toString());

     


    System.out.println(writer.toString());

    转载于:https://www.cnblogs.com/ununie/p/11290232.html

    展开全文
  • org.geotools.geojson.feature.FeatureJSON 将SimpleFeature要素feature转换为GeoJSON字符串输出 val feajson = new FeatureJSON println(feajson.toString(feature)) 将GeoJSON字符串str转换为SimpleFeature...

    重要工具类:

    org.geotools.geojson.feature.FeatureJSON

    将SimpleFeature要素feature转换为GeoJSON字符串输出

    val feajson = new FeatureJSON
    println(feajson.toString(feature))

    将GeoJSON字符串str转换为SimpleFeature要素

    val feajson = new FeatureJSON
    val feature:SimpleFeature=feajson.readFeature(str)

     

    展开全文
  • import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.data.simple.SimpleFeatureIterator; import org.geotools.data.simple....import org.geotools.geojson.feature.FeatureJSON; impo
    import com.alibaba.fastjson.JSONObject;
    import org.geotools.data.shapefile.ShapefileDataStore;
    import org.geotools.data.simple.SimpleFeatureIterator;
    import org.geotools.data.simple.SimpleFeatureSource;
    import org.geotools.geojson.feature.FeatureJSON;
    import org.opengis.feature.simple.SimpleFeature;
    
            long start = System.currentTimeMillis();
            String SHAPE_FILE = "E:\\shp\\区县.shp"; // ShapeFile全路径
            // 使用GeoTools读取ShapeFile文件
            File shapeFile = new File(SHAPE_FILE);
            ShapefileDataStore store = new ShapefileDataStore(shapeFile.toURI().toURL());
            //设置编码
            Charset charset = Charset.forName("GBK");
            store.setCharset(charset);
            SimpleFeatureSource sfSource = store.getFeatureSource();
            SimpleFeatureIterator sfIter = sfSource.getFeatures().features();
            // 从ShapeFile文件中遍历每一个Feature,然后将Feature转为GeoJSON字符串
            String geojson = "";
            while (sfIter.hasNext()) {
                SimpleFeature feature = sfIter.next();
                // Feature转GeoJSON
                FeatureJSON fjson = new FeatureJSON();
                StringWriter writer = new StringWriter();
                fjson.writeFeature(feature, writer);
                String sjson = writer.toString();
                JSONObject featureStr = JSONObject.parseObject(sjson);
                System.out.println("sjson===== >>>> " + featureStr.get("geometry").toString());
                geojson = featureStr.get("geometry").toString();
            }
            System.out.println("数据导入完成,共耗时"+(System.currentTimeMillis() - start)+"ms");
    
    展开全文
  • 在使用GeoTools导出数据的时候,出现了问题也就是使用FeatureJSON导出的json文件的geometry不存在。 我的情况代码如下: final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); ...
  • import org.geotools.geojson.feature.FeatureJSON; import org.geotools.geojson.geom.GeometryJSON; import org.geotools.referencing.crs.DefaultGeographicCRS; import org.geotools.util.Converters; ...
  • import org.geotools.geojson.feature.FeatureJSON; import org.geotools.geometry.jts.ReferencedEnvelope; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import ...
  • geotools等值线生成

    千次阅读 2018-06-03 14:28:44
    org.geotools.geojson.feature.FeatureJSON; import org.opengis.feature.Feature; import org.opengis.feature.simple.SimpleFeature; import wContour.Contour; import wContour.Global.Border; import ...
  • geotools中等值面的生成与OL3中的展示

    千次阅读 热门讨论 2017-08-29 20:58:43
    FeatureJSON fjson = new FeatureJSON(); StringBuffer sb = new StringBuffer(); try { sb.append("{\"type\": \"FeatureCollection\",\"features\": "); FeatureIterator itertor = fc.features(); List...
  • geotools中shp和geojson格式的相互转换

    万次阅读 热门讨论 2017-07-02 08:20:45
    FeatureJSON fjson = new FeatureJSON(); try{ StringBuffer sb = new StringBuffer(); sb.append("{\"type\": \"FeatureCollection\",\"features\": "); File file = new File(shpPath); ...
  • shape文件上传与展示

    千次阅读 2018-01-30 13:01:44
    概述 本文讲述如何在OL中结合GeoTools实现shp数据的上传与展示。 流程 实现效果 使用技术 jquery插件uploadify和ServletFileUpload实现shp文件的上传; ZipFile实现zip文件的解压;...1、前端代码
  • ShapeFile数据到mongodb的导入

    千次阅读 2016-09-17 21:38:01
    FeatureJSON fjson = new FeatureJSON() ; StringWriter writer = new StringWriter() ; fjson .writeFeature (feature, writer) ; String sjson = writer .toString () ; System .out .println (sjson) ; ...
  • MongoDB导入Shapefile数据

    千次阅读 2016-10-01 14:06:35
    FeatureJSON fjson = new FeatureJSON() ; StringWriter writer = new StringWriter() ; fjson .writeFeature (feature, writer) ; String sjson = writer .toString () ; Document doc = Document .parse...
  • // 指定GeometryJSON构造器,15位小数 FeatureJSON fjson_15 = new FeatureJSON(new GeometryJSON(15)); // 读取为FeatureCollection FeatureCollection featureCollection = fjson_15.readFeatureCollection(json)...
  • FeatureJSON fjson = new FeatureJSON(); LineString lineString = (LineString)reader.read("LINESTRING (254058.76074485347 475001.2186020431, 255351.04293761664 474966.9279243938)"); // 按照TYPE中声明的...
  • scala中用json

    千次阅读 2018-03-24 18:49:43
    val DenseFeatue = featureJson.obj.get("DenseFeature").get.asInstanceOf[JSONArray] val DenseF = DenseFeatue.list(0).asInstanceOf[JSONObject].obj.get("Features").get.asInstanceOf[JSONArray].list for( e ...
  • json格式生成

    2013-05-28 21:45:00
    JSONObject featureJson = JSONObject.fromObject(data); JSONObject jObj =null; List<JSONObject> f2list =new ArrayList(); ; if(ids !=null && !ids.equalsIgnoreCase("") ){ String [] arrID = ids.split...
  • ArcGIS 10.1 for Server 扩展开发(SOE)

    千次阅读 2012-11-20 10:38:54
    第一章为什么使用SOE  在ArcGIS 10.1中ArcGIS Server不在支持DCOM方式的连接,这也就意味着我们不能通过本地方式的连接使用ArcObjects提供的更多功能,所以我们推荐一种新的方式来实现这些功能,这种方式就是SOE...
  • 最近在找java中json处理库,找了三个常见的类库:fastjson,Gson,jackson 在实际使用中,fastjson写法最简单,jackson写法最繁。 看fastjson的论坛,其作者温少号称“ gson性能极差!g并非google的缩写,是龟速的...
  • FeatureJSON featureJSON = new FeatureJSON(new GeometryJSON(7)); featureBuilder.add(geotoolPoint); featureBuilder.add(sat.getSatId()); featureBuilder.add(1); SimpleFeature ...
  • 一、遇到的问题 1. 无法导入成功 2. org.geotools.StyleFactory is not an ImageIO SPI class ...调整为jdk1.8就ok了 3. Error parsing epsg:4326 as crs id 换一种geojson的crs 的json串 4. resolution will not be ...
  • feature转化为Json对象

    2011-08-15 15:21:03
    feature转化为Json对象,有时我们需要用CallbackResult把feature对象转换成json,然后在客户端做处理
  • geojson文件与shape文件的相互转换

    千次阅读 2019-10-13 21:44:54
    } /** * shp转换为Geojson * @param shpPath * @return */ public static void shape2Geojson(String shpPath, String jsonPath){ FeatureJSON featureJson = new FeatureJSON(); try{ BufferedWriter out =new ...
  • FeatureJSON fjson = new FeatureJSON(); try { StringBuilder sb = new StringBuilder(); sb.append("{\"type\": \"FeatureCollection\",\"features\": "); File file = new File(shpPath); ShapefileDataStore ...
  • FeatureJSON featureJSON = new FeatureJSON(); SimpleFeature simpleFeature = null; FeatureCollection featureCollection = null; try { simpleFeature = featureJSON.readFeature(geoJson); featureCollection ...
  • }, /*** * 加省市边界 */ addProvince() { qxn.features.forEach((featureJSON) => { let feature = new GeoJSON().readFeature(featureJSON); feature.set("name", feature.values_.NAME); feature.setStyle(new ...
  • Leaflet制作专题图

    2021-02-12 22:51:39
    三、前端 json.js: var getFeatures = function(){ var featureJson=province.geojson中的内容 return featureJson; } html:  各省/直辖市政商关系健康指数 四、总结 Leaflet无疑是最轻量的地图前端了。...
  • FeatureJSON fjson = new FeatureJSON(gjson); FeatureCollection, SimpleFeature> features = fjson.readFeatureCollection(in); 插一句:如果是 geojson 字符串呢?只需要: Reader reader = new StringReader...
  •  FeatureJSON featureJSON = new FeatureJSON();  FeatureCollection featureCollection = featureJSON.readFeatureCollection(new FileInputStream(geojsonpath));  SimpleFeatureType geojsontype = ...
  • GeoJson的生成与解析一、wkt格式的geometry转成json格式二、json格式转wkt格式三、json格式的数据进行解析四、Java读写geojson五、geotools读取shp文件5.1 pom.xml5.2 读取shp文件六、Geotools中Geometry对象与...

空空如也

空空如也

1 2 3 4 5 ... 7
收藏数 125
精华内容 50
关键字:

featurejson