【问题标题】:Adding time to a KML file in Java using JAK使用 JAK 向 Java 中的 KML 文件添加时间
【发布时间】:2017-11-19 19:54:01
【问题描述】:

我正在尝试为我的 KML 文件添加时间,但我不知道如何添加。我知道根据我需要在坐标之前添加它的格式,但我找不到正确的命令.. 非常感谢您的帮助 =) 这是我到目前为止的代码:

String time=filteredStrings.get(i).get(4);
String timestamp=TimeConvert(time); // a function to get the right time format
String Location=filteredStrings.get(i).get(1)+","+filteredStrings.get(i).get(0);    
    doc.createAndAddPlacemark().withName("point"+i).withOpen(Boolean.TRUE).createAndSetTimeStamp().addToObjectSimpleExtension(timestamp)
            .createAndSetPoint().addToCoordinates(Location);

【问题讨论】:

    标签: java timestamp kml jak


    【解决方案1】:

    createAndSetTimeStamp() 方法返回一个 TimeStamp 对象而不是地标,因此在创建时间戳后设置位置不起作用。

    只需创建一个地标对象,然后在其上设置位置和时间。

        Placemark place =  doc.createAndAddPlacemark().withName("point1")
                .withOpen(Boolean.TRUE);
        place.createAndSetPoint().addToCoordinates(Location);
        place.createAndSetTimeStamp().withWhen("2017-11-22T00:00:00Z");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-03
      • 1970-01-01
      相关资源
      最近更新 更多