private void LoadArealFeatures() { cdbDatabase = fpsCDB.GetCDBDatabase(); #if UNITY_ANDROID string filepath = UnityEngine.Application.persistentDataPath; #else string filepath = cdbDatabase.Path; #endif string databaseName = cdbDatabase.name; databaseName = databaseName.Replace('.', '_'); var feats = Cognitics.CDB.Shapefile.ReadFeatures(filepath + "/" + databaseName + "Areal.shp"); if (polyPoints.Count != 0) { polyPoints.Clear(); } foreach (Feature f in feats) { GeoAPI.Geometries.Coordinate[] coords = f.Geometry.Coordinates; foreach (GeoAPI.Geometries.Coordinate c in coords) { var geoCoords = new Cognitics.CoordinateSystems.GeographicCoordinates(); geoCoords.Longitude = c.X; geoCoords.Latitude = c.Y; var cartCoords = geoCoords.TransformedWith(cdbDatabase.Projection); polyPoints.Add(new Vector3((float)cartCoords.X, (float)c.Z, (float)cartCoords.Y)); } ArealObject ao = arealObject.GetComponent <ArealObject>(); ao.title.GetComponent <TMP_InputField>().text = f.Attributes["Title"].ToString(); ao.description.GetComponent <TMP_InputField>().text = f.Attributes["Description"].ToString(); ao.SetArealText(); polyScript.DrawPoly(ref arealObject); } }
private void LoadPoints() { database = cdbButton.GetComponent <FilePanel_SelectCDB>().GetCDBDatabase(); if (database == null) { return; } #if UNITY_ANDROID filepath = UnityEngine.Application.persistentDataPath; #else filepath = database.Path; #endif database = cdbButton.GetComponent <FilePanel_SelectCDB>().GetCDBDatabase(); string databasename = database.name; databasename = databasename.Replace('.', '_'); string name = filepath + "/" + databasename + "POI.shp"; var feats = Cognitics.CDB.Shapefile.ReadFeatures(name); foreach (Feature f in feats) { GeoAPI.Geometries.Coordinate[] coords = f.Geometry.Coordinates; var geoCoords = new Cognitics.CoordinateSystems.GeographicCoordinates(); geoCoords.Longitude = coords[0].X; geoCoords.Latitude = coords[0].Y; var cartCoords = geoCoords.TransformedWith(database.Projection); var poi = buttonPrefab.GetComponent <POIButton>(); poi.locationPosition = new Vector3((float)cartCoords.X, (float)coords[0].Z, (float)cartCoords.Y); poi.buttonText = f.Attributes[title].ToString(); Instantiate(buttonPrefab, contentPane.transform); } //for (int i = 0; i < 20; ++i) // Instantiate(buttonPrefab, contentPane.transform); // isFirstTimeLoaded = false; }
private void LoadPointFeatures() { cdbDatabase = fpsCDB.GetCDBDatabase(); #if UNITY_ANDROID string filepath = UnityEngine.Application.persistentDataPath; #else string filepath = cdbDatabase.Path; #endif cdbDatabase = fpsCDB.GetCDBDatabase(); string databaseName = cdbDatabase.name; databaseName = databaseName.Replace('.', '_'); var feats = Cognitics.CDB.Shapefile.ReadFeatures(filepath + "/" + databaseName + "point.shp"); foreach (Feature f in feats) { GeoAPI.Geometries.Coordinate[] coords = f.Geometry.Coordinates; var geoCoords = new Cognitics.CoordinateSystems.GeographicCoordinates(); geoCoords.Longitude = coords[0].X; geoCoords.Latitude = coords[0].Y; var cartCoords = geoCoords.TransformedWith(cdbDatabase.Projection); Vector3 loc = new Vector3((float)cartCoords.X, (float)coords[0].Z, (float)cartCoords.Y); LocationPin lp = locationPin.GetComponent <LocationPin>(); lp.title.GetComponent <TMP_InputField>().text = f.Attributes["Title"].ToString(); lp.description.GetComponent <TMP_InputField>().text = f.Attributes["Description"].ToString(); lp.location.GetComponent <TextMeshProUGUI>().text = f.Geometry.ToString(); lp.SetPinText(); locationPin.SetActive(true); Instantiate(locationPin, loc, Quaternion.identity); locationPin.SetActive(false); lp.ClearFields(); } }
public CartesianCoordinates To(GeographicCoordinates geographicCoordinates) { double y = (geographicCoordinates.Latitude - Origin.Latitude) * metersPerDegree; double x = (geographicCoordinates.Longitude - Origin.Longitude) * scaleAtOriginLatitudeInMeters; return(new CartesianCoordinates(x, y)); }
public void Transform(CartesianCoordinates cartesianCoordinates, out GeographicCoordinates geographicCoordinates) { geographicCoordinates.Latitude = Origin.Latitude + (cartesianCoordinates.Y / metersPerDegree); geographicCoordinates.Longitude = Origin.Longitude + (cartesianCoordinates.X / scaleAtOriginLatitudeInMeters); }
public void Transform(GeographicCoordinates geographicCoordinates, out CartesianCoordinates cartesianCoordinates) { cartesianCoordinates.X = (geographicCoordinates.Longitude - Origin.Longitude) * scaleAtOriginLatitudeInMeters; cartesianCoordinates.Y = (geographicCoordinates.Latitude - Origin.Latitude) * metersPerDegree; }
public FlatEarthProjection(GeographicCoordinates origin) { Origin = origin; scaleAtOriginLatitudeInMeters = GetScaleForLatitudeInMeters(Origin.Latitude); }