Yermo / geoPHPwithFeatures

Advanced geometry operations in PHP with Features Data
Other
5 stars 4 forks source link

Conversion of a single geometry from GPX to JSON and back again loses data. #4

Closed Yermo closed 7 years ago

Yermo commented 7 years ago

Converting the following GPX file to geojson:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  <metadata>
    <link href="http://www.garmin.com">
      <text>Garmin International</text>
    </link>
    <time>2013-05-27T17:23:57Z</time>
  </metadata>
  <wpt lat="35.466436" lon="-83.920083">
    <ele>573.07</ele>
    <name>Deals Gap</name>
    <sym>Waypoint</sym>
  </wpt>
</gpx>

becomes:

{
   "properties" : {
      "link" : [
         {
            "text" : "Garmin International",
            "href" : "http://www.garmin.com"
         }
      ],
      "time" : "2013-05-27T17:23:57Z"
   },
   "type" : "FeatureCollection",
   "features" : [
      {
         "properties" : {
            "name" : "Deals Gap",
            "sym" : "Waypoint",
            "elevation" : "573.07"
         },
         "geometry" : {
            "coordinates" : [
               -83.920083,
               35.466436,
               573.07,
               {
                  "elevation" : "573.07"
               }
            ],
            "type" : "Point"
         },
         "type" : "Feature"
      }
   ]
}  

Converting it back to GPX yields:

<?xml version="1.0"?>
  <metadata>
    <time>2013-05-27T17:23:57Z</time>
  </metadata>
  <wpt lat="35.466436" lon="-83.920083">
    <time>2013-05-27T17:23:57Z</time>
  </wpt>
</gpx>  
Yermo commented 7 years ago

The elevation metadata tag in the geojson should not be present.

Yermo commented 7 years ago

fixed.