Skip to content

Commit

Permalink
Fix bug with kml geometryElements pointed out by Valerio Messina. Don…
Browse files Browse the repository at this point in the history
…'t repeat extrude element, and respect the required sequence for geometryElements.
  • Loading branch information
tsteven4 committed Dec 18, 2016
1 parent 1f5c461 commit 110adaf
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions kml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -868,15 +868,21 @@ static void kml_output_lookat(const Waypoint* waypointp)
writer->writeEndElement(); // Close LookAt tag
}

static void kml_output_positioning(void)
static void kml_output_positioning(bool tessellate)
{
// These elements must be output as a sequence, i.e. in order.
if (extrude) {
writer->writeTextElement("extrude", "1");
}

if (tessellate) {
writer->writeTextElement("tessellate", "1");
}

if (floating) {
writer->writeTextElement("altitudeMode", "absolute");
}

if (extrude) {
writer->writeTextElement("extrude", "1");
}
}

/* Output something interesing when we can for route and trackpoints */
Expand Down Expand Up @@ -1022,11 +1028,7 @@ static void kml_output_point(const Waypoint* waypointp, kml_point_type pt_type)
}

writer->writeStartElement("Point");
kml_output_positioning();

if (extrude) {
writer->writeTextElement("extrude", "1");
}
kml_output_positioning(false);
kml_write_coordinates(waypointp);
writer->writeEndElement(); // Close Point tag

Expand Down Expand Up @@ -1092,8 +1094,7 @@ static void kml_output_tailer(const route_head* header)
writer->writeEndElement(); // Close LineString tag
}
writer->writeStartElement("LineString");
kml_output_positioning();
writer->writeTextElement("tessellate","1");
kml_output_positioning(true);
writer->writeStartElement("coordinates");
writer->writeCharacters("\n");
}
Expand Down Expand Up @@ -1625,7 +1626,7 @@ static void kml_waypt_pr(const Waypoint* waypointp)

// Location
writer->writeStartElement("Point");
kml_output_positioning();
kml_output_positioning(false);
kml_write_coordinates(waypointp);
writer->writeEndElement(); // Close Point tag

Expand Down Expand Up @@ -1760,7 +1761,7 @@ static void kml_mt_hdr(const route_head* header)
writer->writeOptionalTextElement("name", header->rte_name);
writer->writeTextElement("styleUrl", "#multiTrack");
writer->writeStartElement("gx:Track");
kml_output_positioning();
kml_output_positioning(false);

QUEUE_FOR_EACH(&header->waypoint_list, elem, tmp) {
Waypoint* tpt = (Waypoint*)elem;
Expand Down

0 comments on commit 110adaf

Please sign in to comment.