Skip to content
Snippets Groups Projects
Commit b2c813e1 authored by Yuki Kitsukawa's avatar Yuki Kitsukawa Committed by Martins Mozeiko
Browse files

initial commit for opendrive map import

parent 67ce915a
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@ public class MapImport : EditorWindow
string[] importFormats = new string[]
{
"Apollo HD Map", "Lanelet2 Map", "OpenDRIVE"
"Apollo HD Map", "Lanelet2 Map", "OpenDRIVE Map"
};
[MenuItem("Simulator/Import HD Map", false, 110)]
......@@ -75,6 +75,22 @@ public class MapImport : EditorWindow
GUILayout.EndHorizontal();
}
if (importFormats[Selected] == "OpenDRIVE Map")
{
EditorGUILayout.HelpBox("Select File...", UnityEditor.MessageType.Info);
GUILayout.BeginHorizontal();
FileName = EditorGUILayout.TextField(FileName);
if (GUILayout.Button("...", GUILayout.ExpandWidth(false)))
{
var path = EditorUtility.OpenFilePanel("Open OpenDRIVE Map", "", "xodr");
if (!string.IsNullOrEmpty(path))
{
FileName = path;
}
}
GUILayout.EndHorizontal();
}
if (GUILayout.Button(new GUIContent("Import", $"Import {importFormats[Selected]}")))
{
if (string.IsNullOrEmpty(FileName))
......@@ -89,6 +105,11 @@ public class MapImport : EditorWindow
laneLet2MapImporter.ImportLanelet2Map(FileName);
}
if (importFormats[Selected] == "OpenDRIVE Map")
{
OpenDriveMapImporter openDriveMapImporter = new OpenDriveMapImporter();
openDriveMapImporter.ImportOpenDriveMap(FileName);
}
}
}
......
This diff is collapsed.
fileFormatVersion: 2
guid: ddaf0cb52f90088a9bef90dad1094de9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
/**
* Copyright (c) 2019 LG Electronics, Inc.
*
* This software contains code licensed as described in LICENSE.
*
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using Simulator.Map;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using Schemas;
namespace Simulator.Editor
{
public class OpenDriveMapImporter
{
MapOrigin MapOrigin;
public void ImportOpenDriveMap(string filePath)
{
OpenDRIVE odr;
var serializer = new XmlSerializer(typeof(OpenDRIVE));
XmlTextReader reader = new XmlTextReader(filePath);
odr = (OpenDRIVE)serializer.Deserialize(reader);
if (Calculate(filePath))
{
Debug.Log("Successfully imported OpenDRIVE Map!\nNote if your map is incorrect, please check if you have set MapOrigin correctly.");
}
else
{
Debug.Log("Failed to import OpenDRIVE map.");
}
}
public bool Calculate(string filePath)
{
return true;
}
/*
static void ValidationCallback(object sender, ValidationEventArgs args)
{
if (args.Severity == XmlSeverityType.Warning)
Console.Write("WARNING: ");
else if (args.Severity == XmlSeverityType.Error)
Console.Write("ERROR: ");
Console.WriteLine(args.Message);
}
*/
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: e8dd6a2a66c4248c2a9e6d71a47c9b31
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment