| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 | 
							- package org.jeecg.modules.demo.untils;
 
- import com.alibaba.fastjson.JSONArray;
 
- import com.alibaba.fastjson.JSONException;
 
- import com.alibaba.fastjson.JSONObject;
 
- import com.xkcoding.http.util.StringUtil;
 
- import me.zhyd.oauth.log.Log;
 
- import org.springframework.stereotype.Component;
 
- import java.util.ArrayList;
 
- import java.util.List;
 
- @Component
 
- public class geoinfo {
 
-     public String geoinfo(String jd,String wd) {
 
-         ArrayList<String> list=new ArrayList<>();
 
-         JSONObject featureCollection = new JSONObject();
 
-         String type = null;
 
-         String substring;
 
-         String r = null;
 
-         //{"type":"LineString","crs":{"type":"name","properties":{"name":"EPSG:4490"}},"coordinates":[[117.02511407469186,36.58087944812466],[117.02303754894979,36.57606883015553],[117.02144554588087,36.587005199063775],[117.0279866019684,36.58648606762826],[117.02843651587918,36.579633532679416]]}
 
-         //{"crs":{"type":"name","properties":{"name":"EPSG:4490"}},"coordinates":"[[117.21470515847446,36.68296526003463], [117.21191109558109,36.68172842050911], [117.21173959267449,36.684959929690315]]","type":"LinString"}
 
-         //{"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:4490"}},"coordinates":[116.35487452721023,36.195113571900855]}
 
-         try {
 
-             JSONObject properties = new JSONObject();
 
-             properties.put("name","EPSG:4490");
 
-             JSONObject crs = new JSONObject();
 
-             crs.put("type","name");
 
-             crs.put("properties",properties);
 
-             // {"crs":{"type":"name","properties":{"name":"EPSG:4490"}},"type":"LinString","coordinates":[[117.21470515847446,36.68296526003463],[117.21191109558109,36.68172842050911],[117.21173959267449,36.684959929690315]]}
 
-             featureCollection.put("crs",crs);
 
-             if(jd.contains(",")&&wd.contains(",")){
 
-                 String[] a=jd.split(",");
 
-                 String[] b=wd.split(",");
 
-                 for (int i = 0; i <a.length ; i++) {
 
-                     if(StringUtil.isNotEmpty(a[i]) &&StringUtil.isNotEmpty(b[i]) && a[i].contains("°") && b[i].contains("°")){
 
-                         a[i]=Dms2d.Dms2D(a[i]);
 
-                         b[i]=Dms2d.Dms2D(b[i]);
 
-                     }
 
-                     list.add("["+a[i]+","+b[i]+"]");
 
-                 }
 
-                 if(list.get(0).equals(list.get(list.size()-1))){
 
-                     type="Polygon";
 
-                     featureCollection.put("type", type);
 
-                     substring = featureCollection.toString().substring(0, featureCollection.toString().length() - 1);
 
-                     r=substring+","+"\""+"coordinates"+"\""+":"+"["+list.toString().replace(" ","")+"]"+"}";
 
-                 }else {
 
-                     type="LineString";
 
-                     featureCollection.put("type", type);
 
-                     substring = featureCollection.toString().substring(0, featureCollection.toString().length() - 1);
 
-                     r=substring+","+"\""+"coordinates"+"\""+":"+list.toString().replace(" ","")+"}";
 
-                 }
 
-             }else{
 
-                 ArrayList<String> a=new ArrayList<>();
 
-                 if(StringUtil.isNotEmpty(jd) &&StringUtil.isNotEmpty(wd) && jd.contains("°") && wd.contains("°")){
 
-                     jd=Dms2d.Dms2D(jd);
 
-                     wd=Dms2d.Dms2D(wd);
 
-                 }
 
-                 a.add(jd);
 
-                 a.add(wd);
 
-                 type="Point";
 
-                 featureCollection.put("type", type);
 
-                 substring = featureCollection.toString().substring(0, featureCollection.toString().length() - 1);
 
-                 r=substring+","+"\""+"coordinates"+"\""+":"+a.toString().replace(" ","")+"}";
 
-             }
 
-         } catch (JSONException e) {
 
-             Log.error("can't save json object: "+e.toString());
 
-         }
 
-         System.out.println(r);
 
-         return r;
 
-     }
 
- }
 
 
  |