Skip to content

Commit

Permalink
Mapsアップデート
Browse files Browse the repository at this point in the history
LineRendererのLoopを設定できるようになりました。
DBFエンコーディングのデフォルトをShiftJISにしました。
  • Loading branch information
sonny-unity committed Mar 18, 2024
1 parent 69e9d48 commit 9e3a4bc
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 10 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added PlateauToolkit.Maps/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions PlateauToolkit.Maps/Editor/DbfReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class DbfRecord

public enum SupportedEncoding
{
UTF8, // 0
ShiftJIS // 1
ShiftJIS, // 0
UTF8 // 1
}

namespace PlateauToolkit.Maps.Editor
Expand Down
13 changes: 11 additions & 2 deletions PlateauToolkit.Maps/Editor/GeoJsonLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ public class GeoJsonLoader : IDisposable
GameObject m_PositionMarkerSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
GameObject m_PointDataPrefab;
GameObject m_PointMarkerDefaultPrefab;
bool m_LoopLineRenderer;

public GeoJsonLoader(GameObject pointDataPrefab = null)
public GeoJsonLoader(bool closeLineRenderer, GameObject pointDataPrefab = null)
{
m_GeoRef = GameObject.FindObjectOfType<CesiumGeoreference>();
m_PositionMarkerSphere.transform.SetParent(m_GeoRef.transform);
m_PositionMarkerSphere.AddComponent<CesiumGlobeAnchor>();
m_PointDataPrefab = pointDataPrefab;
m_LoopLineRenderer = closeLineRenderer;
}

public bool ReadAll(string pathToFolder, float height, float lineWidth)
Expand Down Expand Up @@ -199,7 +201,14 @@ GameObject InstantiateShape(GameObject shapeParent, GameObject parentObject, str
instance.transform.parent = parentObject.transform;

LineRenderer lineRenderer = instance.GetComponent<LineRenderer>();
lineRenderer.loop = true;
if (m_LoopLineRenderer)
{
lineRenderer.loop = true;
}
else
{
lineRenderer.loop = false;
}
lineRenderer.startWidth = lineWidth;
lineRenderer.endWidth = lineWidth;

Expand Down
8 changes: 5 additions & 3 deletions PlateauToolkit.Maps/Editor/PlateauToolkitMapsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class PlateauToolkitMapsWindow : EditorWindow
string m_GisTargetFolderName;
int m_SelectedShpRenderingIndex;
int m_GisModeIndex;
bool m_CloseLineRendererLoop;
static readonly string[] k_ShpRenderingModes = { "Mesh", "Line" };
static readonly string[] k_GisMode = { "SHP", "GeoJson" };

Expand Down Expand Up @@ -503,15 +504,16 @@ bool TabButton(string iconPath, Tab tab)
{
EditorGUILayout.LabelField("描画タイプ", "ジオメトリから判断する");
}
if (m_SelectedShpRenderingIndex == 1)
if (m_SelectedShpRenderingIndex == 1 || m_GisModeIndex != 0)
{
m_LineRendererWidth = EditorGUILayout.FloatField("GISの線幅", m_LineRendererWidth);
m_CloseLineRendererLoop = EditorGUILayout.Toggle("LineRenderer Loop", m_CloseLineRendererLoop);
}
if (GUILayout.Button("GISデータの読み込み"))
{
if (m_GisModeIndex == 0)
{
using (m_ShapefileRenderManager = new ShapefileRenderManager(m_GisTargetFolderName, m_SelectedShpRenderingIndex, m_GisRenderHeight, m_MergeMesh, m_SupportedEncoding, m_PointDataPrefab))
using (m_ShapefileRenderManager = new ShapefileRenderManager(m_GisTargetFolderName, m_SelectedShpRenderingIndex, m_GisRenderHeight, m_MergeMesh, m_CloseLineRendererLoop, m_SupportedEncoding, m_PointDataPrefab))
{
if (m_ShapefileRenderManager.Read(m_LineRendererWidth))
{
Expand All @@ -528,7 +530,7 @@ bool TabButton(string iconPath, Tab tab)
}
else
{
using (GeoJsonLoader geoJsonLoader = new GeoJsonLoader(m_PointDataPrefab))
using (GeoJsonLoader geoJsonLoader = new GeoJsonLoader(m_CloseLineRendererLoop, m_PointDataPrefab))
{
if (geoJsonLoader.ReadAll(m_GisTargetFolderName, m_GisRenderHeight, m_LineRendererWidth))
{
Expand Down
13 changes: 11 additions & 2 deletions PlateauToolkit.Maps/Editor/ShapefileRenderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ public class ShapefileRenderManager : IDisposable
string m_CurrentRenderingObject;
float m_RenderHeight;
bool m_MergeMeshes;
bool m_LoopLineRenderer;

GameObject m_PointDataPrefab;

public ShapefileRenderManager(string folderPath, int renderMode, float renderHeight, bool mergeMeshes, SupportedEncoding supportedEncoding, GameObject pointDataPrefab = null)
public ShapefileRenderManager(string folderPath, int renderMode, float renderHeight, bool mergeMeshes, bool loopLineRenderer, SupportedEncoding supportedEncoding, GameObject pointDataPrefab = null)
{
m_GeoRef = GameObject.FindObjectOfType<CesiumGeoreference>();
m_FolderPath = folderPath;
m_RenderMode = renderMode;
m_RenderHeight = renderHeight;
m_MergeMeshes = mergeMeshes;
m_LoopLineRenderer = loopLineRenderer;
m_PointDataPrefab = pointDataPrefab;
m_SupportedStringEncoding = supportedEncoding;
m_DbfReader = null;
Expand Down Expand Up @@ -246,7 +248,14 @@ void DrawPolygonOrPolyline(IShape shape, int index, float lineWidth, GameObject
lineRenderer.startWidth = lineWidth; // Set the start width
lineRenderer.endWidth = lineWidth;
lineRenderer.SetPositions(partPointsWorld.ToArray());
lineRenderer.loop = true;
if (m_LoopLineRenderer)
{
lineRenderer.loop = true;
}
else
{
lineRenderer.loop = false;
}
if (!string.IsNullOrEmpty(m_DbfFilePath) && dbfRead && dbfReader.GetRecordLength() == m_ListOfShapes.Count)
{
AttachMetadata(shpParentInstance, record);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.unity.plateautoolkit.maps",
"displayName": "PLATEAU SDK-Maps-Toolkit for Unity",
"version": "1.0.1",
"version": "1.0.2",
"unity": "2021.3",
"description": "PLATEAUの3D都市モデルを用いた空間解析、可視化、建築情報との連携など、地図アプリ開発等を行うためのツールキットです。",
"keywords": [
Expand Down

0 comments on commit 9e3a4bc

Please sign in to comment.