Skip to content

Commit

Permalink
Merge pull request #10 from PLATEAU-Toolkits-Internal/main
Browse files Browse the repository at this point in the history
Merge for readme edit
  • Loading branch information
unity-takeuchi authored Dec 25, 2023
2 parents ffe1014 + 17bba3b commit 7775d42
Show file tree
Hide file tree
Showing 33 changed files with 3,444 additions and 3,442 deletions.
42 changes: 21 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License

Copyright (c) 2023 unity-shimizu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License
Copyright (c) 2023 unity-shimizu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
114 changes: 57 additions & 57 deletions PlateauToolkit.Maps/Editor/CheckMacChipType.cs
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
using UnityEngine;
using System.Diagnostics;
using System;

namespace PlateauToolkit.Maps.Editor
{
public static class CheckMacChipType
{
public static string GetMacChipType()
{
if (Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXEditor)
{
return GetMacArchitecture();
}
else
{
return "";
}
}

static string GetMacArchitecture()
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "/usr/sbin/sysctl";
startInfo.Arguments = "-n machdep.cpu.brand_string";
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;

string result = "";
try
{
using (Process process = Process.Start(startInfo))
{
result = process.StandardOutput.ReadToEnd().Trim();
process.WaitForExit();
}
}
catch (Exception ex)
{
UnityEngine.Debug.LogError("Error fetching Mac architecture: " + ex.Message);
}

if (result.Contains("Apple"))
{
return "M1"; // or other Apple silicon chips
}
else if (result.Contains("Intel"))
{
return "Intel";
}
else
{
return "Unknown";
}
}
}
using UnityEngine;
using System.Diagnostics;
using System;

namespace PlateauToolkit.Maps.Editor
{
public static class CheckMacChipType
{
public static string GetMacChipType()
{
if (Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXEditor)
{
return GetMacArchitecture();
}
else
{
return "";
}
}

static string GetMacArchitecture()
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "/usr/sbin/sysctl";
startInfo.Arguments = "-n machdep.cpu.brand_string";
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;

string result = "";
try
{
using (Process process = Process.Start(startInfo))
{
result = process.StandardOutput.ReadToEnd().Trim();
process.WaitForExit();
}
}
catch (Exception ex)
{
UnityEngine.Debug.LogError("Error fetching Mac architecture: " + ex.Message);
}

if (result.Contains("Apple"))
{
return "M1"; // or other Apple silicon chips
}
else if (result.Contains("Intel"))
{
return "Intel";
}
else
{
return "Unknown";
}
}
}
}
116 changes: 58 additions & 58 deletions PlateauToolkit.Maps/Editor/ConversionEpsg.cs
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
using GeoAPI.CoordinateSystems.Transformations;
using GeoAPI.CoordinateSystems;
using ProjNet.Converters.WellKnownText;
using ProjNet.CoordinateSystems;
using ProjNet.CoordinateSystems.Transformations;
using System;
using System.Text;
using Unity.Mathematics;

namespace PlateauToolkit.Maps.Editor
{
public static class ConversionEpsg
{
public static double3 ConvertEpsgToWgs(IfcCoordinate ifcCoo)
{
// Provided IFC coordinates
double[] ifcCoords = ifcCoo.Coordinates; // The origin of the IFC file
double eastings = ifcCoo.Eastings;
double northings = ifcCoo.Northings;
double height = ifcCoo.Height;
double xAbcessa = ifcCoo.XAbscissa;
double yOrdinate = ifcCoo.XOrdinate;
double scale = ifcCoo.Scale;

// Convert to EPSG:6677
double[] epsgCoords = ConvertToEpsg(ifcCoords, eastings, northings, height, xAbcessa, yOrdinate, scale);

// Define the coordinate systems
string jgd2011Wkt = "PROJCS[\"JGD2011 / Japan Plane Rectangular CS IX\",GEOGCS[\"JGD2011\",DATUM[\"Japanese_Geodetic_Datum_2011\",SPHEROID[\"GRS 1980\",6378137,298.257222101],TOWGS84[0,0,0,0,0,0,0]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"6668\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",36],PARAMETER[\"central_meridian\",139.833333333333],PARAMETER[\"scale_factor\",0.9999],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"6677\"]]";

ICoordinateSystem jgd2011 = (ICoordinateSystem)CoordinateSystemWktReader.Parse(jgd2011Wkt, Encoding.UTF8);
ICoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84;

// Define a coordinate transformation factory
CoordinateTransformationFactory ctFactory = new CoordinateTransformationFactory();

// Create a coordinate transformation from EPSG:6677 to WGS84
ICoordinateTransformation transformer = ctFactory.CreateFromCoordinateSystems(jgd2011, wgs84);
// Transform the point to WGS84
double[] res = transformer.MathTransform.Transform(epsgCoords);
double3 final = new double3(res[0], res[1], res[2] / 100);
return final;
}

static double[] ConvertToEpsg(double[] ifcCoords, double eastings, double northings, double height, double xAbcessa, double yOrdinate, double scale)
{
// Rotate and scale
double angle = Math.Atan2(yOrdinate, xAbcessa);
double rotatedX = scale * (ifcCoords[0] * Math.Cos(angle) - ifcCoords[1] * Math.Sin(angle));
double rotatedY = scale * (ifcCoords[0] * Math.Sin(angle) + ifcCoords[1] * Math.Cos(angle));
double scaledZ = scale * ifcCoords[2];

// Translate
double[] epsgCoords = new double[] { rotatedX + eastings, rotatedY + northings, scaledZ + height };

return epsgCoords;
}
}
using GeoAPI.CoordinateSystems.Transformations;
using GeoAPI.CoordinateSystems;
using ProjNet.Converters.WellKnownText;
using ProjNet.CoordinateSystems;
using ProjNet.CoordinateSystems.Transformations;
using System;
using System.Text;
using Unity.Mathematics;

namespace PlateauToolkit.Maps.Editor
{
public static class ConversionEpsg
{
public static double3 ConvertEpsgToWgs(IfcCoordinate ifcCoo)
{
// Provided IFC coordinates
double[] ifcCoords = ifcCoo.Coordinates; // The origin of the IFC file
double eastings = ifcCoo.Eastings;
double northings = ifcCoo.Northings;
double height = ifcCoo.Height;
double xAbcessa = ifcCoo.XAbscissa;
double yOrdinate = ifcCoo.XOrdinate;
double scale = ifcCoo.Scale;

// Convert to EPSG:6677
double[] epsgCoords = ConvertToEpsg(ifcCoords, eastings, northings, height, xAbcessa, yOrdinate, scale);

// Define the coordinate systems
string jgd2011Wkt = "PROJCS[\"JGD2011 / Japan Plane Rectangular CS IX\",GEOGCS[\"JGD2011\",DATUM[\"Japanese_Geodetic_Datum_2011\",SPHEROID[\"GRS 1980\",6378137,298.257222101],TOWGS84[0,0,0,0,0,0,0]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"6668\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",36],PARAMETER[\"central_meridian\",139.833333333333],PARAMETER[\"scale_factor\",0.9999],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"6677\"]]";

ICoordinateSystem jgd2011 = (ICoordinateSystem)CoordinateSystemWktReader.Parse(jgd2011Wkt, Encoding.UTF8);
ICoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84;

// Define a coordinate transformation factory
CoordinateTransformationFactory ctFactory = new CoordinateTransformationFactory();

// Create a coordinate transformation from EPSG:6677 to WGS84
ICoordinateTransformation transformer = ctFactory.CreateFromCoordinateSystems(jgd2011, wgs84);
// Transform the point to WGS84
double[] res = transformer.MathTransform.Transform(epsgCoords);
double3 final = new double3(res[0], res[1], res[2] / 100);
return final;
}

static double[] ConvertToEpsg(double[] ifcCoords, double eastings, double northings, double height, double xAbcessa, double yOrdinate, double scale)
{
// Rotate and scale
double angle = Math.Atan2(yOrdinate, xAbcessa);
double rotatedX = scale * (ifcCoords[0] * Math.Cos(angle) - ifcCoords[1] * Math.Sin(angle));
double rotatedY = scale * (ifcCoords[0] * Math.Sin(angle) + ifcCoords[1] * Math.Cos(angle));
double scaledZ = scale * ifcCoords[2];

// Translate
double[] epsgCoords = new double[] { rotatedX + eastings, rotatedY + northings, scaledZ + height };

return epsgCoords;
}
}
}
Loading

0 comments on commit 7775d42

Please sign in to comment.