From 8b6c5a321c3d9a9f6e6531497b645e41b2937c21 Mon Sep 17 00:00:00 2001
From: Sergi Hernandez Juan <shernand@iri.upc.edu>
Date: Wed, 6 May 2020 10:25:28 +0200
Subject: [PATCH] Read the contact point whatever the type of the
 predecessor/successor. Removed the NA.

---
 OpenRoadEd/OpenDrive/OpenDriveXmlParser.cpp | 10 ++++------
 Samples/iri_test.xodr                       | 22 ++++++++++-----------
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/OpenRoadEd/OpenDrive/OpenDriveXmlParser.cpp b/OpenRoadEd/OpenDrive/OpenDriveXmlParser.cpp
index 1a97bcc..481f08d 100644
--- a/OpenRoadEd/OpenDrive/OpenDriveXmlParser.cpp
+++ b/OpenRoadEd/OpenDrive/OpenDriveXmlParser.cpp
@@ -182,13 +182,12 @@ bool  OpenDriveXmlParser::ReadRoadLink (Road* road, TiXmlElement *node, short in
 	{
 		string elementType; 
 		string elementId;
-		string contactPoint="NA";
+		string contactPoint;
 
 		int checker=TIXML_SUCCESS;
 		checker+=node->QueryStringAttribute("elementType",&elementType);
 		checker+=node->QueryStringAttribute("elementId",&elementId);
-		if (elementType.compare("road")==0)
-			checker+=node->QueryStringAttribute("contactPoint",&contactPoint);
+		checker+=node->QueryStringAttribute("contactPoint",&contactPoint);
 
 		if (checker!=TIXML_SUCCESS)
 		{
@@ -203,13 +202,12 @@ bool  OpenDriveXmlParser::ReadRoadLink (Road* road, TiXmlElement *node, short in
 	{
 		string elementType; 
 		string elementId;
-		string contactPoint="NA";
+		string contactPoint;
 
 		int checker=TIXML_SUCCESS;
 		checker+=node->QueryStringAttribute("elementType",&elementType);
 		checker+=node->QueryStringAttribute("elementId",&elementId);
-		if (elementType.compare("road")==0)
-			checker+=node->QueryStringAttribute("contactPoint",&contactPoint);
+		checker+=node->QueryStringAttribute("contactPoint",&contactPoint);
 
 		if (checker!=TIXML_SUCCESS)
 		{
diff --git a/Samples/iri_test.xodr b/Samples/iri_test.xodr
index 2e6966a..0b8cb10 100644
--- a/Samples/iri_test.xodr
+++ b/Samples/iri_test.xodr
@@ -4,7 +4,7 @@
     <road name="road0" length="2.5000000000000000e+01" id="0" junction="-1">
         <link>
             <predecessor elementType="road" elementId="9" contactPoint="end" />
-            <successor elementType="junction" elementId="1" contactPoint="NA" />
+            <successor elementType="junction" elementId="1" contactPoint="end" />
         </link>
         <type s="0.0000000000000000e+00" type="town" />
         <planView>
@@ -44,7 +44,7 @@
     </road>
     <road name="road1" length="2.5000000000000000e+01" id="1" junction="-1">
         <link>
-            <predecessor elementType="junction" elementId="1" contactPoint="NA" />
+            <predecessor elementType="junction" elementId="1" contactPoint="end" />
             <successor elementType="road" elementId="2" contactPoint="start" />
         </link>
         <type s="0.0000000000000000e+00" type="town" />
@@ -221,7 +221,7 @@
     <road name="road5" length="2.5000000000000000e+01" id="5" junction="-1">
         <link>
             <predecessor elementType="road" elementId="4" contactPoint="end" />
-            <successor elementType="junction" elementId="2" contactPoint="NA" />
+            <successor elementType="junction" elementId="2" contactPoint="end" />
         </link>
         <type s="0.0000000000000000e+00" type="town" />
         <planView>
@@ -261,10 +261,10 @@
     </road>
     <road name="road6" length="2.5000000000000000e+01" id="6" junction="-1">
         <link>
-            <predecessor elementType="junction" elementId="2" contactPoint="NA" />
+            <predecessor elementType="junction" elementId="2" contactPoint="end" />
             <successor elementType="road" elementId="7" contactPoint="start" />
         </link>
-        <type s="0.0000000000000000e+00" type="Default" />
+        <type s="0.0000000000000000e+00" type="town" />
         <planView>
             <geometry s="0.0000000000000000e+00" x="2.5000000000000000e+01" y="8.0000000000000000e+01" hdg="3.1415926540000001e+00" length="2.5000000000000000e+01">
                 <line />
@@ -352,7 +352,7 @@
             <predecessor elementType="road" elementId="7" contactPoint="end" />
             <successor elementType="road" elementId="9" contactPoint="start" />
         </link>
-        <type s="0.0000000000000000e+00" type="Default" />
+        <type s="0.0000000000000000e+00" type="town" />
         <planView>
             <geometry s="0.0000000000000000e+00" x="-1.0000000000000000e+01" y="7.0000000000000000e+01" hdg="4.7123889800000001e+00" length="6.0000000000000000e+01">
                 <line />
@@ -437,8 +437,8 @@
     </road>
     <road name="road10" length="6.0000000000000000e+01" id="10" junction="-1">
         <link>
-            <predecessor elementType="junction" elementId="1" contactPoint="NA" />
-            <successor elementType="junction" elementId="2" contactPoint="NA" />
+            <predecessor elementType="junction" elementId="1" contactPoint="end" />
+            <successor elementType="junction" elementId="2" contactPoint="end" />
         </link>
         <type s="0.0000000000000000e+00" type="town" />
         <planView>
@@ -478,7 +478,7 @@
     </road>
     <road name="road11" length="5.0000000000000000e+01" id="11" junction="-1">
         <link>
-            <predecessor elementType="junction" elementId="1" contactPoint="NA" />
+            <predecessor elementType="junction" elementId="1" contactPoint="end" />
         </link>
         <type s="0.0000000000000000e+00" type="town" />
         <planView>
@@ -518,9 +518,9 @@
     </road>
     <road name="road12" length="2.0000000000000000e+01" id="12" junction="-1">
         <link>
-            <predecessor elementType="junction" elementId="1" contactPoint="NA" />
+            <predecessor elementType="junction" elementId="1" contactPoint="end" />
         </link>
-        <type s="0.0000000000000000e+00" type="Default" />
+        <type s="0.0000000000000000e+00" type="town" />
         <planView>
             <geometry s="0.0000000000000000e+00" x="4.5000000000000000e+01" y="1.0000000000000000e+01" hdg="7.8539800000000004e-01" length="2.0000000000000000e+01">
                 <line />
-- 
GitLab