Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MeshCode検索 #180

Merged
merged 16 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
0f4e37d
tile download url changed to https
seventhX Jun 16, 2023
0b0112d
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
seventhX Jun 16, 2023
666592d
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
seventhX Jun 22, 2023
98dbfa3
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
seventhX Jun 27, 2023
9176199
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
seventhX Jul 6, 2023
7721075
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
seventhX Jul 7, 2023
21eef23
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Jul 20, 2023
87f8f6c
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Aug 18, 2023
b601873
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Aug 21, 2023
6446ff6
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Oct 11, 2023
b138ae5
Search by Mesh code
sevendev Oct 16, 2023
5271e28
build error fix
sevendev Oct 16, 2023
6ad5724
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Oct 16, 2023
546d8b6
範囲外エラー
sevendev Oct 20, 2023
83f5c56
text changed
sevendev Oct 23, 2023
24c2045
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Oct 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 52 additions & 4 deletions Runtime/CityImport/AreaSelector/AreaSelectorBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ internal class AreaSelectorBehaviour : MonoBehaviour
private GeoReference geoReference;
private bool prevSceneCameraRotationLocked;
private GSIMapLoaderZoomSwitch mapLoader;
private Extent EntireExtent;
#if UNITY_EDITOR
private EditorWindow prevEditorWindow;
MeshCodeSearchWindow meshSearchwindow;
#endif


public static bool IsAreaSelectEnabled { get; set; }

#if UNITY_EDITOR
Expand Down Expand Up @@ -92,9 +93,9 @@ private void Start()
this.gizmosDrawer = drawerObj.AddComponent<AreaSelectGizmosDrawer>();
this.gizmosDrawer.Init(meshCodes, this.datasetSourceConfig, this.coordinateZoneID, out this.geoReference);
// this.availablePackageFlags = packageFlags;
var entireExtent = CalcExtentCoversAllMeshCodes(meshCodes);
this.mapLoader = new GSIMapLoaderZoomSwitch(this.geoReference, entireExtent);
SetInitialCamera(entireExtent);
EntireExtent = CalcExtentCoversAllMeshCodes(meshCodes);
this.mapLoader = new GSIMapLoaderZoomSwitch(this.geoReference, EntireExtent);
SetInitialCamera(EntireExtent);
#if (UNITY_EDITOR && UNITY_2019_2_OR_NEWER)
SceneVisibilityManager.instance.DisableAllPicking();
#endif
Expand Down Expand Up @@ -140,6 +141,7 @@ private void OnDisable()
{
#if UNITY_EDITOR
SceneView.lastActiveSceneView.isRotationLocked = this.prevSceneCameraRotationLocked;
meshSearchwindow?.Close();
#endif
this.mapLoader?.Dispose();
}
Expand Down Expand Up @@ -244,5 +246,51 @@ private static void RotateSceneViewCameraDown()
scene.rotation = Quaternion.Euler(90, 0, 0);
#endif
}

internal void ShowMeshCodeSearchWindow()
{
#if UNITY_EDITOR
meshSearchwindow = MeshCodeSearchWindow.ShowWindow();
meshSearchwindow.Init(this);
#endif
}

internal bool SearchByMeshCode(string code)
{
#if UNITY_EDITOR
try
{
MeshCode meshCode = MeshCode.Parse(code);
var extent = meshCode.Extent;
var min = geoReference.Project(extent.Min);
var max = geoReference.Project(extent.Max);
var center = geoReference.Project(extent.Center);
var centerPos = center.ToUnityVector();
var initialCameraPos = new Vector3(centerPos.x, 0, centerPos.z);

//範囲チェック
var intersection = Extent.Intersection(extent, EntireExtent, true);
var failedCoord = new GeoCoordinate(-99, -99, -99);
if (intersection.Min.Equals(failedCoord) && intersection.Max.Equals(failedCoord))
{
return false;
}

SceneView.lastActiveSceneView.pivot = initialCameraPos;
// シーンビューのカメラが全体を映すようにします。
SceneView.lastActiveSceneView.size = Mathf.Abs((float)(max.Z - min.Z) / 2f);
}
catch(Exception e)
{
Debug.LogError($"code:{code} Error:{e.Message}");
return false;
}

meshSearchwindow?.Close();
meshSearchwindow = null;
#endif
return true;
}

}
}
5 changes: 5 additions & 0 deletions Runtime/CityImport/AreaSelector/AreaSelectorGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ private static void DrawAreaSelectionInsideWindow(int id)
areaSelector.EndAreaSelection();
}
EditorGUI.EndDisabledGroup();
if (GUILayout.Button("メッシュコード検索"))
{
//Meshcode
areaSelector.ShowMeshCodeSearchWindow();
}
if (GUILayout.Button("キャンセル"))
{
areaSelector.CancelAreaSelection();
Expand Down
90 changes: 90 additions & 0 deletions Runtime/CityImport/AreaSelector/MeshCodeSearchWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using PLATEAU.Dataset;
using PLATEAU.Geometries;
using PLATEAU.Native;
using PLATEAU.Util;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;

namespace PLATEAU.CityImport.AreaSelector
{
#if UNITY_EDITOR
internal class MeshCodeSearchWindow : UnityEditor.EditorWindow
{
private AreaSelectorBehaviour areaSelector;

string code = "";
string errorText = "";

internal static MeshCodeSearchWindow ShowWindow()
{
MeshCodeSearchWindow wnd = GetWindow<MeshCodeSearchWindow>();
wnd.titleContent = new GUIContent("メッシュコード入力");
wnd.minSize = wnd.maxSize = new Vector2(380, 140);
return wnd;
}

internal void Init(AreaSelectorBehaviour areaSelector)
{
this.areaSelector = areaSelector;
code = errorText = "";
this.autoRepaintOnSceneChange = true;
}


private void OnGUI()
{
//code = "53395680";
var style = new GUIStyle
{
padding = new RectOffset(8, 8, 4, 4),
margin = new RectOffset(8, 8, 4, 4)
};

var errorLabelStyle = new GUIStyle(EditorStyles.label)
{
normal ={ textColor = Color.red }
};

EditorGUILayout.BeginVertical(style);
EditorGUILayout.LabelField("メッシュコードを入力してください。");
EditorGUILayout.LabelField("(6桁または8桁の数字)");
EditorGUILayout.EndVertical();

EditorGUILayout.BeginVertical(style);
code = EditorGUILayout.TextField("", code);
EditorGUILayout.LabelField(errorText, errorLabelStyle);
EditorGUILayout.EndVertical();

EditorGUILayout.BeginHorizontal(style);
if (GUILayout.Button("キャンセル", GUILayout.Height(20), GUILayout.MaxWidth(80)))
{
this.Close();
}

if (GUILayout.Button("Ok", GUILayout.Height(20), GUILayout.MaxWidth(80)))
{
if (!int.TryParse(code, out var res))
{
errorText = "数字を入力してください";
}
else if (code.Length != 6 && code.Length != 8)
{
errorText = "6桁または8桁の数字を入力してください";
}
else if(!areaSelector.SearchByMeshCode(code))
{
errorText = "メッシュコードが範囲外です";
}
else
{
this.Close();
}
}
EditorGUILayout.EndHorizontal();
}
}
#endif
}
11 changes: 11 additions & 0 deletions Runtime/CityImport/AreaSelector/MeshCodeSearchWindow.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,14 @@ public void SwitchLodIcon(int lod, bool isCheck)
{
showLods.Remove(lod);
}
#if UNITY_EDITOR
foreach (var view in this.viewDict)
{
#if UNITY_EDITOR
view.Value?.CalculateLodViewParam(SceneView.lastActiveSceneView.camera, showLods);
#endif
}
#endif
}
}
}
5 changes: 3 additions & 2 deletions libplateau/CSharpPLATEAU/Native/Extent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ public Extent(GeoCoordinate min, GeoCoordinate max)
/// <summary>
/// 共通部分を返します。
/// なければ (-99, -99, -99), (-99, -99, -99)を返します。
/// 高さを考慮しない場合は、ignoreHeightをtrueにします。
/// </summary>
public static Extent Intersection(Extent op1, Extent op2)
public static Extent Intersection(Extent op1, Extent op2, bool ignoreHeight = false)
{
var max = GeoCoordinate.Max(op1.Max, op2.Max);
var min = GeoCoordinate.Min(op1.Min, op2.Min);
var intersectSize = op1.Size() + op2.Size() - (max - min);
if (intersectSize.Latitude <= 0 || intersectSize.Latitude <= 0 || intersectSize.Height <= 0)
if (intersectSize.Latitude <= 0 || intersectSize.Latitude <= 0 || (!ignoreHeight && intersectSize.Height <= 0))
return new Extent(new GeoCoordinate(-99,-99,-99), new GeoCoordinate(-99, -99, -99));
var minMax = GeoCoordinate.Min(op1.Max, op2.Max);
var maxMin = GeoCoordinate.Max(op1.Min, op2.Min);
Expand Down