| | |
| | | String geomProperty = "the_geom"; |
| | | String idProperty = "ID"; |
| | | String nameProperty = "name"; |
| | | String firmIdProperty = "firmId"; |
| | | String firmNameProperty = "firmName"; |
| | | |
| | | //设置图形类型 |
| | | if ("Polygon".equals(geomType)) { |
| | |
| | | //设置对应属性类型 |
| | | tb.add(idProperty, String.class); |
| | | tb.add(nameProperty, String.class); |
| | | tb.add(firmIdProperty, String.class); |
| | | tb.add(firmNameProperty, String.class); |
| | | |
| | | //设置默认geometry |
| | | tb.setDefaultGeometry(geomProperty); |
| | |
| | | for (Map<String, Object> map : dataPropertiesList) { |
| | | feature = writer.next(); |
| | | //属性赋值 geometry要赋值wkt格式的 |
| | | feature.setAttribute(geomProperty, new WKTReader().read((MapUtil.getStr(map, "geometry")))); |
| | | if (map.containsKey("geometry")) { |
| | | feature.setAttribute(geomProperty, new WKTReader().read((MapUtil.getStr(map, "geometry")))); |
| | | } |
| | | feature.setAttribute(idProperty, MapUtil.getStr(map, idProperty)); |
| | | feature.setAttribute(nameProperty, MapUtil.getStr(map, nameProperty)); |
| | | feature.setAttribute(firmIdProperty, MapUtil.getStr(map, firmIdProperty)); |
| | | feature.setAttribute(firmNameProperty, MapUtil.getStr(map, firmNameProperty)); |
| | | // String description = MapUtil.getStr(map, "描述"); |
| | | // if (CharSequenceUtil.isNotBlank(description)) { |
| | | // feature.setAttribute(descriptionProperty, description); |
| | |
| | | if (json.getJSONObject("properties").get("Name")!= null) { |
| | | shpDTO.put("name",json.getJSONObject("properties").getString("Name")); |
| | | } |
| | | if (json.getJSONObject("properties").get("TYPE")!= null) { |
| | | shpDTO.put("name",json.getJSONObject("properties").getString("TYPE")); |
| | | } |
| | | // 所属公司名称 |
| | | if (json.getJSONObject("properties").get("name_1")!= null) { |
| | | shpDTO.put("firmName",json.getJSONObject("properties").getString("name_1")); |
| | | } |
| | | if (json.getJSONObject("properties").get("QYMC")!= null) { |
| | | shpDTO.put("firmName",json.getJSONObject("properties").getString("QYMC")); |
| | | } |
| | | dtoList.add(shpDTO); |
| | | } catch (NumberFormatException e) { |
| | | System.err.println("处理单个特征时发生错误:" + e.getMessage()); |