void AddFeature(NetTopologySuite.Features.Feature feature, Color color, float elev) { Vector3[] points = null; if (feature.Geometry is NetTopologySuite.Geometries.LineString) { var linear = (NetTopologySuite.Geometries.LineString)feature.Geometry; if (!linear.IsValid) { return; } points = new Vector3[linear.Count]; for (int i = 0; i < points.Length; ++i) { var geographicCoordinates = new GeographicCoordinates(linear[i].Y, linear[i].X); var cartesianCoordinates = geographicCoordinates.TransformedWith(Database.Projection); points[i] = new Vector3((float)cartesianCoordinates.X, elev, (float)cartesianCoordinates.Y); } } if (points == null) { return; } var featureGameObject = new GameObject(); featureGameObject.transform.SetParent(Database.gameObject.transform); LineRenderer lineRenderer = featureGameObject.AddComponent <LineRenderer>(); lineRenderer.positionCount = points.Length; lineRenderer.SetPositions(points); lineRenderer.startWidth = 0.1f; lineRenderer.endWidth = 0.1f; lineRenderer.startColor = color; lineRenderer.endColor = color; lineRenderer.sharedMaterial = LineMaterial; }
private void TaskLoad(QuadTreeNode node) { try { var featureData = new GSFeatureDataNode(); DataByNode[node] = featureData; featureData.Features = ReadFeatures(node); foreach (var feature in featureData.Features) { var geographicCoordinates = new GeographicCoordinates(feature.Geometry.Centroid.Y, feature.Geometry.Centroid.X); var cartesianCoordinates = geographicCoordinates.TransformedWith(Database.Projection); float elev = Database.TerrainElevationAtLocation(geographicCoordinates); Vector3 position = new Vector3((float)cartesianCoordinates.X, elev, (float)cartesianCoordinates.Y); featureData.PositionByFeature[feature] = position; } } catch (Exception e) { Debug.LogException(e); } node.IsLoaded = true; node.IsLoading = false; }
public void GetHashCode_ShouldReturnUniqueHashCode() { var latitude = 0.0d; var longitudeOne = 0.0d; var longitudeTwo = 180.0d; var longitudeThree = -180.0d; var longitudeFour = 18.0d; var longitudeFive = -18.0d; var targetOne = new GeographicCoordinates(latitude, longitudeOne); var targetTwo = new GeographicCoordinates(latitude, longitudeTwo); var targetThree = new GeographicCoordinates(latitude, longitudeThree); var targetFour = new GeographicCoordinates(latitude, longitudeFour); var targetFive = new GeographicCoordinates(latitude, longitudeFive); // Act. var results = new Int32[] { targetOne.GetHashCode(), targetTwo.GetHashCode(), targetThree.GetHashCode(), targetFour.GetHashCode(), targetFive.GetHashCode() }; // Assert. results.Should().OnlyHaveUniqueItems(); }
public void Initialize() { // //Debug.Log("Tile == NULL ?" + (tile == null)); List <Vector3> positions = this.tile.MapBounds.WorldCoordsCorners(); Vector3 origin = GeographicCoordinates.ConvertLonLatToXY(TileManager.OriginLongitude, TileManager.OriginLatitude, 0f).Vector3FromVector2XZ(); Vector3 heightVector = new Vector3(0f, height, 0f); corners.Add(positions[0] - origin + heightVector); corners.Add(positions[1] - origin + heightVector); corners.Add(positions[2] - origin + heightVector); corners.Add(positions[3] - origin + heightVector); MeshRenderer meshRenderer = gameObject.GetComponent <MeshRenderer>(); MeshFilter meshFilter = gameObject.GetComponent <MeshFilter>(); //Debug.Log("Origin : " + origin); //Debug.Log("Position0 : " + positions[0]); mesh = new Mesh(); //mesh.CreateQuad(positions[0] - origin, positions[1] - origin, positions[2] - origin, positions[3] - origin); mesh.CreateQuad(corners[0], corners[1], corners[2], corners[3]); meshFilter.mesh = mesh; meshRenderer.sharedMaterial = new Material(Shader.Find("Transparent/Diffuse")); meshRenderer.sharedMaterial.mainTexture = tile.Image; //transform.position = positions[0] - origin; //Debug.Log(tile.ToString()); }
public void HandleGlobeClick(GameObject sender, double lat, double lon) { if (cdbDatabase == null) { return; } if (lat < cdbDatabase.GeographicBounds.MinimumCoordinates.Latitude) { return; } if (lat > cdbDatabase.GeographicBounds.MaximumCoordinates.Latitude) { return; } if (lon < cdbDatabase.GeographicBounds.MinimumCoordinates.Longitude) { return; } if (lon > cdbDatabase.GeographicBounds.MaximumCoordinates.Longitude) { return; } ModeButton.UpdateState(2); OnFileSelect2(path); var geographicCoordinates = new GeographicCoordinates(lat, lon); var cartesianCoordinates = geographicCoordinates.TransformedWith(cdbDatabase.Projection); UserObject.transform.position = new Vector3((float)cartesianCoordinates.X, 20f, (float)cartesianCoordinates.Y); cdbDatabase.SetLODBracketsForDetail(); SetDetailMode.Invoke(true); OptionsCanvas.GetComponent <Options>().uiControlsCanvas.SetActive(OptionsCanvas.GetComponent <Options>().uiControlsCheckmark.activeSelf); sender.SetActive(false); }
public List <GeographicCoordinates> ExistingGeocells() { var result = new List <GeographicCoordinates>(); for (int ilat = -90; ilat < 90; ++ilat) { GeographicCoordinates tileCoordinates = new GeographicCoordinates(ilat, 0.0f); string latitudeSubdirectory = System.IO.Path.Combine(Database.Path, "Tiles", tileCoordinates.TileLatitudeSubdirectory); if (!System.IO.Directory.Exists(latitudeSubdirectory)) { continue; } int tileWidth = tileCoordinates.Latitude.TileWidth; for (int ilon = -180; ilon < 180; ilon += tileWidth) { tileCoordinates.Longitude = ilon; string longitudeDirectory = System.IO.Path.Combine(Database.Path, "Tiles", tileCoordinates.TileSubdirectory); if (System.IO.Directory.Exists(longitudeDirectory)) { result.Add(tileCoordinates); } } } return(result); }
public void SetCenterTile(int x, int y) { this.centerTileNumbers = new Vector2(x, y); Vector2 newCenterCoords = GeographicCoordinates.TileToWorldPos(x, y, this.zoomLevel); this.centerLongitude = newCenterCoords.x; this.centerLatitude = newCenterCoords.y; }
public CartesianCoordinates To(GeographicCoordinates geographicCoordinates) { var cartesianCoordinates = Projection.To(geographicCoordinates); cartesianCoordinates.X *= Scale; cartesianCoordinates.Y *= Scale; return(cartesianCoordinates); }
/// <summary> /// 1 3 /// /// 0 2 /// </summary> /// <returns></returns> public List <Vector3> WorldCoordsCorners() { List <Vector3> corners = new List <Vector3>(); corners.Add(GeographicCoordinates.ConvertLonLatToXY(west, south, 0).Vector3FromVector2XZ()); corners.Add(GeographicCoordinates.ConvertLonLatToXY(west, north, 0).Vector3FromVector2XZ()); corners.Add(GeographicCoordinates.ConvertLonLatToXY(east, south, 0).Vector3FromVector2XZ()); corners.Add(GeographicCoordinates.ConvertLonLatToXY(east, north, 0).Vector3FromVector2XZ()); return(corners); }
private void CalculateDegreesPerPixel() { // TileToWorldPosition vom CenterTile Vector2 tileToWorldCenterTile = GeographicCoordinates.TileToWorldPos(Mathf.RoundToInt(centerTileNumbers.x), Mathf.RoundToInt(centerTileNumbers.y), this.zoomLevel); // TileToWorldPosition vom ein Tile weiter Vector2 tileToWorldCenterNextTile = GeographicCoordinates.TileToWorldPos(Mathf.RoundToInt(centerTileNumbers.x + 1), Mathf.RoundToInt(centerTileNumbers.y), this.zoomLevel); // Distanz zwischen Punkten geteilt durch TileSize in Pixeln = degreesPerPixel this.degreesPerPixel = (tileToWorldCenterNextTile.x - tileToWorldCenterTile.x) / this.tileSize; }
public void Parse_ShouldReturnValidResult_ForValidArgument_WithSpacing() { // Arrange. var input = "42.42, -32.7"; // Act. var result = GeographicCoordinates.Parse(input); // Assert. result.Should().Be(new GeographicCoordinates(42.42d, -32.7d)); }
public void ToString_ShouldReturnValidResult() { // Arrange. var latitude = 42.05d; var longitude = -42.3d; var target = new GeographicCoordinates(latitude, longitude); // Act. var result = target.ToString(); // Assert. result.Should().Be("42.05,-42.3"); }
static void ProjectPolygon(ref Polygon polygon, double lattitude, double longitude) { GeographicCoordinates coords = new GeographicCoordinates(lattitude, longitude); FlatEarthProjection fep = new FlatEarthProjection(coords); for (int i = 0; i < polygon.verts.Count - 1; i += 3) { double x, y; fep.TransformToCartesian(polygon.verts[i + 1], polygon.verts[i], out x, out y); polygon.verts[i] = y; polygon.verts[i + 1] = x; } }
/// <summary> /// /// </summary> public void ScrollControl() { if (editorMode == 0) { if (Event.current.isMouse) { if (Event.current.button == 0 && Event.current.type == EventType.MouseUp) { if (tileMap.isOnMap(Event.current.mousePosition)) { tileMap.centerTileNumbers = tileMap.MouseToTilePosition((int)Event.current.mousePosition.x, (int)Event.current.mousePosition.y); Vector2 newPos = GeographicCoordinates.TileToWorldPos((int)tileMap.centerTileNumbers.x, (int)tileMap.centerTileNumbers.y, tileMap.zoomLevel); tileMap.centerLatitude = newPos.y; tileMap.centerLongitude = newPos.x; tileMap.changed = true; } } } } if (Event.current.isKey && Event.current.type == EventType.KeyUp) { // Handle KeyScrolling Vector2 newPos = GeographicCoordinates.TileToWorldPos((int)tileMap.centerTileNumbers.x, (int)tileMap.centerTileNumbers.y, tileMap.zoomLevel); switch (Event.current.keyCode) { case KeyCode.UpArrow: newPos = GeographicCoordinates.TileToWorldPos((int)tileMap.centerTileNumbers.x, (int)tileMap.centerTileNumbers.y - 1, tileMap.zoomLevel); break; case KeyCode.DownArrow: newPos = GeographicCoordinates.TileToWorldPos((int)tileMap.centerTileNumbers.x, (int)tileMap.centerTileNumbers.y + 1, tileMap.zoomLevel); break; case KeyCode.LeftArrow: newPos = GeographicCoordinates.TileToWorldPos((int)tileMap.centerTileNumbers.x - 1, (int)tileMap.centerTileNumbers.y, tileMap.zoomLevel); break; case KeyCode.RightArrow: newPos = GeographicCoordinates.TileToWorldPos((int)tileMap.centerTileNumbers.x + 1, (int)tileMap.centerTileNumbers.y, tileMap.zoomLevel); break; default: break; } tileMap.centerLatitude = newPos.y; tileMap.centerLongitude = newPos.x; tileMap.changed = true; //Event.current.Use(); } }
public void Parse_ShouldRaiseArgumentNullException_ForNullArgument() { // Arrange. var input = (String)null; // Act. var action = new Action(() => { var result = GeographicCoordinates.Parse(input); }); // Assert. action.Should().Throw <ArgumentNullException>(); }
public void Parse_ShouldRaiseArgumentOutOfRangeException_ForOutOfRangeArgument() { // Arrange. var input = "42.42,-320.7"; // Act. var action = new Action(() => { var result = GeographicCoordinates.Parse(input); }); // Assert. action.Should().Throw <ArgumentOutOfRangeException>(); }
public void ToByteArray_ShouldReturnValidResult() { // Arrange. var latitude = 42.05d; var longitude = -42.3d; var target = new GeographicCoordinates(latitude, longitude); // Act. var result = target.ToByteArray(); // Assert. result.Should().NotBeNull(); result.Length.Should().Be(16); }
public void Parse_ShouldRaiseFormatException_ForInvalidFormatArgument() { // Arrange. var input = "42.42 : -32.7"; // Act. var action = new Action(() => { var result = GeographicCoordinates.Parse(input); }); // Assert. action.Should().Throw <FormatException>(); }
public float TerrainElevationAtLocation(GeographicCoordinates location) { foreach (var elem in ActiveTiles) { Tile tile = elem.Value; if (location.Latitude < tile.GeographicBounds.MinimumCoordinates.Latitude) { continue; } if (location.Longitude < tile.GeographicBounds.MinimumCoordinates.Longitude) { continue; } if (location.Latitude > tile.GeographicBounds.MaximumCoordinates.Latitude) { continue; } if (location.Longitude > tile.GeographicBounds.MaximumCoordinates.Longitude) { continue; } var point = location.TransformedWith(Projection); var cartesianBounds = tile.GeographicBounds.TransformedWith(Projection); double spcX = (cartesianBounds.MaximumCoordinates.X - cartesianBounds.MinimumCoordinates.X) / tile.MeshDimension; double spcZ = (cartesianBounds.MaximumCoordinates.Y - cartesianBounds.MinimumCoordinates.Y) / tile.MeshDimension; double orgX = cartesianBounds.MinimumCoordinates.X; double orgZ = cartesianBounds.MinimumCoordinates.Y; float xComponent = (float)point.X - (float)orgX; float zComponent = (float)point.Y - (float)orgZ; int xIndex = Math.Min(tile.MeshDimension - 2, (int)Math.Floor(xComponent / spcX)); int zIndex = Math.Min(tile.MeshDimension - 2, (int)Math.Floor(zComponent / spcZ)); int[] indices = new int[4]; Vector3[] vertices = new Vector3[4]; indices[0] = zIndex * tile.MeshDimension + xIndex; indices[1] = indices[0] + 1; indices[2] = indices[0] + tile.MeshDimension; indices[3] = indices[0] + tile.MeshDimension + 1; for (int i = 0; i < indices.Length; ++i) { vertices[i] = tile.vertices[indices[i]]; } ref Vector3 a = ref vertices[0]; ref Vector3 b = ref vertices[1];
public void EqualityComparer_ShouldReturnValidResult() { // Arrange. var latitude = 0.0d; var longitudeOne = 0.0d; var longitudeTwo = 180.0d; var targetOne = new GeographicCoordinates(latitude, longitudeOne); var targetTwo = new GeographicCoordinates(latitude, longitudeOne); var targetThree = new GeographicCoordinates(latitude, longitudeTwo); // Assert. (targetOne.Equals(targetTwo)).Should().BeTrue(); (targetTwo.Equals(targetThree)).Should().BeFalse(); (targetTwo == targetOne).Should().BeTrue(); (targetThree == targetOne).Should().BeFalse(); (targetOne != targetThree).Should().BeTrue(); (targetTwo != targetOne).Should().BeFalse(); }
/// <summary> /// /// </summary> public void CaculateValues(Rect windowRect, float xOffset, float yOffset) { this.xOffset = xOffset; this.yOffset = yOffset; this.mapWidth = windowRect.width - this.xOffset; this.mapHeight = windowRect.height - this.yOffset; this.tileSize = (int)(this.mapWidth / 5f); this.centerTileNumbers = GeographicCoordinates.WorldToTilePos(this.centerLongitude, this.centerLatitude, this.zoomLevel); this.centerTileCoordsOnWindow = new Vector2((float)(this.mapWidth / 2f + this.xOffset), (float)(this.mapHeight / 2f + this.yOffset)); CalculateDegreesPerPixel(); // Methode --> pixelKoordinaten --> LonLat // Methode --> LonLat --> Pixelkoordinaten }
public GeographicBounds ExistingBounds() { int inorth = (int)Latitude.MinValue; int isouth = (int)Latitude.MaxValue; int ieast = (int)Longitude.MinValue; int iwest = (int)Longitude.MaxValue; for (int ilat = -90; ilat < 90; ++ilat) { GeographicCoordinates tileCoordinates = new GeographicCoordinates(ilat, 0.0f); string latitudeDirectory = System.IO.Path.Combine(Database.Path, "Tiles", tileCoordinates.TileLatitudeSubdirectory); if (!System.IO.Directory.Exists(latitudeDirectory)) { continue; } isouth = Math.Min(isouth, ilat); inorth = Math.Max(inorth, ilat + 1); int tileWidth = tileCoordinates.Latitude.TileWidth; for (int ilon = -180; ilon < 180; ilon += tileWidth) { tileCoordinates.Longitude = ilon; if ((ilon >= iwest) && (ilon < ieast)) { ilon = ieast - 1; continue; } string longitudeDirectory = System.IO.Path.Combine(latitudeDirectory, tileCoordinates.TileLongitudeString); if (!System.IO.Directory.Exists(longitudeDirectory)) { continue; } iwest = Math.Min(iwest, ilon); ieast = Math.Max(ieast, ilon + tileWidth); } } var southWest = new GeographicCoordinates(isouth, iwest); var northEast = new GeographicCoordinates(inorth, ieast); return(new GeographicBounds(southWest, northEast)); }
// This is the old, faster version that gets elevation at SW corner of a triangle pair. // TODO: if we want to keep this around for quick but inaccurate lookups, we could rename it appropriately public float TerrainElevationAtLocation(GeographicCoordinates location) { var tiles = ActiveTiles(); foreach (var tile in tiles) { if (location.Latitude < tile.GeographicBounds.MinimumCoordinates.Latitude) { continue; } if (location.Longitude < tile.GeographicBounds.MinimumCoordinates.Longitude) { continue; } if (location.Latitude > tile.GeographicBounds.MaximumCoordinates.Latitude) { continue; } if (location.Longitude > tile.GeographicBounds.MaximumCoordinates.Longitude) { continue; } var point = location.TransformedWith(Projection); var bounds = tile.GeographicBounds.TransformedWith(Projection); var spacingX = (bounds.MaximumCoordinates.X - bounds.MinimumCoordinates.X) / tile.MeshDimension; var spacingY = (bounds.MaximumCoordinates.Y - bounds.MinimumCoordinates.Y) / tile.MeshDimension; int indexX = (int)((point.X - bounds.MinimumCoordinates.X) / spacingX); int indexY = (int)((point.Y - bounds.MinimumCoordinates.Y) / spacingY); int index = (indexY * tile.MeshDimension) + indexX; if (index >= tile.vertices.Length) { index = tile.vertices.Length - 1; } var vertex = tile.vertices[index]; return(vertex.y); } return(float.MaxValue); }
//////////////////////////////////////////////////////////////////////////////// public void QuadTreeDataUpdate(QuadTreeNode node) // QuadTreeDelegate { #if UNITY_EDITOR if (node.IsActive) { var sw = node.GeographicBounds.MinimumCoordinates; var ne = node.GeographicBounds.MaximumCoordinates; var se = new GeographicCoordinates(sw.Latitude, ne.Longitude); var nw = new GeographicCoordinates(ne.Latitude, sw.Longitude); var swc = sw.TransformedWith(Database.Projection); var sec = se.TransformedWith(Database.Projection); var nwc = nw.TransformedWith(Database.Projection); var nec = ne.TransformedWith(Database.Projection); var elev = 100.0f; var swv = new Vector3((float)swc.X, elev, (float)swc.Y); var sev = new Vector3((float)sec.X, elev, (float)sec.Y); var nwv = new Vector3((float)nwc.X, elev, (float)nwc.Y); var nev = new Vector3((float)nec.X, elev, (float)nec.Y); Debug.DrawLine(swv, sev); Debug.DrawLine(swv, nwv); Debug.DrawLine(nwv, nev); Debug.DrawLine(sev, nev); } #endif if (!node.IsActive) { return; } if (!node.IsLoaded) { return; } if (Database.SystemMemoryLimitExceeded) { return; } //if (HasLoadedDecendents(node)) // return; var maxdist = Database.LODSwitchByObject[this].MaxDistance * Database.Projection.Scale; GSFeatureDataNode featureData = null; if (!DataByNode.TryGetValue(node, out featureData)) { return; } for (int i = 0; i < 1; ++i) { if (featureData.Features.Count < 1) { return; } if (Time.frameCount % 10 != 0) { var tempList = new List <GameObject>(); foreach (var go in featureData.LoadingGameObjects) { if (!go.GetComponent <Model>().Loaded) { tempList.Add(go); } } featureData.LoadingGameObjects = tempList; } if (featureData.LoadingGameObjects.Count > 4) { return; } int index = featureData.Features.Count - 1; var feature = featureData.Features[index]; var dist2 = (featureData.PositionByFeature[feature] - featureData.CameraPosition).sqrMagnitude; if (dist2 > maxdist * maxdist) { return; } lock (featureData.Features) { featureData.Features.RemoveAt(index); } try { var modelGameObject = GenerateModel(node, feature); if (modelGameObject != null) { featureData.GameObjects.Add(modelGameObject); featureData.LoadingGameObjects.Add(modelGameObject); } } catch (Exception e) { Debug.LogException(e); } } }
IEnumerator Load() { var position = gameObject.transform.position; var cartesianCoordinates = new CartesianCoordinates(position.x, position.z); GeographicCoordinates = cartesianCoordinates.TransformedWith(ModelManager.Database.Projection); if (ZipFilename == null) { MeshKey = System.IO.Path.GetFullPath(System.IO.Path.Combine(Path, FltFilename)); } else { MeshKey = System.IO.Path.Combine(System.IO.Path.GetFullPath(System.IO.Path.Combine(Path, ZipFilename)), FltFilename); } while (Meshes == null) { Meshes = MeshManager.LodForName(MeshKey); yield return(new WaitForSecondsRealtime(0.1f)); } if (Meshes.Count == 0) { gameObject.SetActive(false); yield break; } while (MaterialNames == null) { MaterialNames = MeshManager.TexturesForMeshName(MeshKey); yield return(new WaitForSecondsRealtime(0.1f)); } yield return(null); foreach (var name in MaterialNames) { string matKey = System.IO.Path.GetFullPath(System.IO.Path.Combine(Path, name)); MaterialEntries[matKey] = MaterialManager.Entry(matKey); Materials[name] = null; } yield return(null); bool done = false; while (!done) { done = true; foreach (var name in MaterialNames) { if (Materials[name] == null) { string matKey = System.IO.Path.GetFullPath(System.IO.Path.Combine(Path, name)); if (!MaterialEntries[matKey].Loaded) { done = false; break; } Materials[name] = MaterialEntries[matKey].Material; } } if (!done) { yield return(new WaitForSecondsRealtime(0.1f)); } } yield return(null); var meshFilter = gameObject.AddComponent <MeshFilter>(); CurrentLodIndex = Meshes.Count - 1; // Start at min LOD (??? - abrinton) meshFilter.mesh = Meshes[CurrentLodIndex].mesh; yield return(null); var meshEntry = MeshManager.MeshByName[MeshKey]; MeshRenderer = gameObject.AddComponent <MeshRenderer>(); if (Materials.Values.Count != 0) { // Check that the materials in question actually have textures, or we'll be assigning bad materials // and in some cases we have more materials than submeshes. List <Material> materialsToAssign = new List <Material>(); // There needs to be one material per submesh, and the mapping must be correct for (int i = 0; i < Meshes[0].mesh.subMeshCount; ++i) { int texturePatternIndex = meshEntry.submeshToTexturePatternIndex[i]; if (texturePatternIndex != -1) { materialsToAssign.Add(Materials[meshEntry.Textures[texturePatternIndex]]); } } MeshRenderer.sharedMaterials = materialsToAssign.ToArray(); } else { // Don't override single default material, just spit out a warning Debug.LogWarningFormat("no materials specified for {0}", FltFilename); } MeshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; MeshRenderer.receiveShadows = false; PropertyBlock = new MaterialPropertyBlock(); ++ModelManager.ValidCount; Loaded = true; InvokeRepeating("UpdateElevation", 1.0f, 2.0f); }
public GeographicBounds(GeographicCoordinates minCoordinates, GeographicCoordinates maxCoordinates) { MinimumCoordinates = minCoordinates; MaximumCoordinates = maxCoordinates; }
public ScaledFlatEarthProjection(GeographicCoordinates origin, double scale) { Projection = new FlatEarthProjection(origin); Scale = scale; }
internal GbGeographicSpatialInfo(GeographicCoordinates location) { Location = location; }
public void Awake() { geoCoords = target as GeographicCoordinates; }
protected void Start() { if (Feature.Geometry == null) { Debug.LogErrorFormat("feature {0} has no geometry!!!", name); gameObject.SetActive(false); return; } if (!Feature.Geometry.IsSimple) { Debug.LogWarningFormat("feature {0} geometry is not simple!!!", name); } transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity); var attributeNames = new List <string>(Feature.Attributes.GetNames()); var attributeValues = new List <object>(Feature.Attributes.GetValues()); for (int i = 0; i < attributeNames.Count; i++) { Attributes[attributeNames[i]] = attributeValues[i]; } // Copy the attributes into a field viewable from the inspector (for easy copy/paste debugging) string str = ""; for (int i = 0; i < attributeNames.Count; i++) { str += string.Format("{0}: {1}\n", attributeNames[i], attributeValues[i].ToString()); } //var multiPolygon = Feature.Geometry as NetTopologySuite.Geometries.MultiPolygon; //if (multiPolygon != null) // str += "MP\n"; textAttributes = str; name = GetName(); int id = -1; GetId(out id); if (id == contiguousUSA_Id) // skip contiguous US airspace that seems to be in every airspace shapefile { gameObject.SetActive(false); return; } Rebuild(); if (textInfo != null) { textInfo.text = name; textInfo.color = new Color(0.5f, 0.5f, 0.5f, 1f); if (vertices != null && vertices.Length > 0) { var geographicCoordinates = new GeographicCoordinates(Feature.Geometry.Centroid.Y, Feature.Geometry.Centroid.X); var cartesianCoordinates = geographicCoordinates.TransformedWith(Database.Projection); Vector3 vec = new Vector3((float)cartesianCoordinates.X, vertices[0].y, (float)cartesianCoordinates.Y); textInfo.transform.position = vec; textInfo.transform.localScale = Vector3.one; } } }