是否可以将HERE flexible-polyline直接写入Postgis?

Is it possible to write HERE flexible-polyline directly into Postgis?

是否可以直接将 HERE 灵活多段线写入我的 Postgis/Postgres 数据库,无需解码,转换为文本,然后使用 [=43 制作几何图形=](ST_MakePoint(...)?恐怕没有可能性(除了 Google-encoded-Polyline)。或者有什么可以使用的吗?

背景:我正在测试 HERE-API 的路由。我找到了 Java-source 来解码来自 Github 的结果折线:https://github.com/heremaps/flexible-polyline。因此我可以从这个 flexxible-polyline-String

中读取坐标

我的要求是:

但现在我想将此点列表转换为 Postgis。我希望使用现有的功能,例如ST_LineFromEncodedPolyline 来自 Postgis。不幸的是,这不是 return 有效结果,因为它基于 Google encoding/decoding 算法。 ST_LineFromEncodedPolyline 的结果是(这清楚地表明这些折线压缩之间存在巨大差异):

SELECT ST_AsEWKT(ST_LineFromEncodedPolyline('BG8_9j7Cy11iXsBlBoBrEnBrErJr.....
--Result:
SRID=4326;LINESTRING(0.00004 -0.00002,0.0042 -0.00015,0.00422 -0.00405,0.00431 -0.00104,0.0048 ...

有什么办法吗?使用乘数从 HERE-String 获取此几何图形?

由于我找不到答案或有效的解决方案,我写信希望不要...我的结果如下:

  1. Java 杰克逊解析器

    ObjectMapper oJacksonObjectMapper = new ObjectMapper();
    IOUtils.copy(oRespIputStream, oStringWriter, Charset.forName(StandardCharsets.UTF_8.name()) );
    JsonNode oJsonNode = oJacksonObjectMapper.readTree(sJsonString);
    
  2. RoutingHereSection.java

    @JsonProperty("polyline")
    private String polylineString;
    private List<LatLngZ> listeLatLonCoords; 
    private String listeLatLonCoordsAsPostgisString;
    
  3. PolylineEncoderDecoder.java(来自Github)添加方法:

    public String getKoordinatenMitSpaceFuerPostgis() {
       return ""+ lng +" "+ lat;   // => not lat/lng for Postgis
    }
    
  4. 解析坐标串

      this.listeLatLonCoords = PolylineEncoderDecoder.decode( this.polylineString );
    
  5. 循环创建 LINESTRING

            this.listeLatLonCoordsAsPostgisString = "";
            if (this.getListeLatLonCoordsAnzahl()>0) {
                String sGeom = "LINESTRING(";
                for (int ii=0; ii<listeLatLonCoords.size();ii++) {
                    if (ii>0) { sGeom +=", "; }
                    sGeom += listeLatLonCoords.get(ii).getKoordinatenMitSpaceFuerPostgis();
                }
                sGeom += ")";
                this.listeLatLonCoordsAsPostgisString = sGeom;
            }
    
  6. INSERT 使用 Jdbc

    String sSql = "INSERT INTO mytable ST_GeomFromText( ? ,4326) "
    Object[] oParam = new Object[] { oSectionReturn.getListeLatLonCoordsAsPostgisString() } 
    int[] oType = new int[] { java.sql.Types.VARCHAR }
    getJdbcTemplate().execute( sSql )
    

就是这样......或多或少。