Ejemplo n.º 1
0
        public static bool Transform(this DMesh3 dMesh, SpatialReference to)
        {
            string crs = dMesh.FindMetadata("CRS") as string;

            if (crs != null && crs != "")
            {
                SpatialReference from = new SpatialReference(null);
                if (crs.Contains("+proj"))
                {
                    from.ImportFromProj4(crs);
                }
                else if (crs.StartsWith("epsg") || crs.StartsWith("EPSG"))
                {
                    int epsg = int.Parse(crs.Split(':')[1]);
                    from.ImportFromEPSG(epsg);
                }
                else
                {
                    from.ImportFromWkt(ref crs);
                };
                try {
                    CoordinateTransformation trans = new CoordinateTransformation(from, to);
                    for (int i = 0; i < dMesh.VertexCount; i++)
                    {
                        if (dMesh.IsVertex(i))
                        {
                            Vector3d vertex = dMesh.GetVertex(i);
                            double[] dV     = new double[3] {
                                vertex.x, vertex.y, vertex.z
                            };
                            trans.TransformPoint(dV);
                            AppState.instance.mapTrans.TransformPoint(dV);
                            dMesh.SetVertex(i, new Vector3d(dV));
                        }
                    }
                    ;
                    return(true);
                } catch {
                    return(false);
                }
            }
            try {
                for (int i = 0; i < dMesh.VertexCount; i++)
                {
                    if (dMesh.IsVertex(i))
                    {
                        Vector3d vertex = dMesh.GetVertex(i);
                        double[] dV     = new double[3] {
                            vertex.x, vertex.y, vertex.z
                        };
                        AppState.instance.mapTrans.TransformPoint(dV);
                        dMesh.SetVertex(i, new Vector3d(dV));
                    }
                }
                ;
                return(true);
            } catch {
                return(false);
            }
        }
Ejemplo n.º 2
0
 public override Dictionary <string, object> GetMetadata()
 {
     if (mesh != null)
     {
         return(mesh.FindMetadata("properties") as Dictionary <string, object>);
     }
     else
     {
         return(transform.parent.GetComponent <IVirgisFeature>().GetMetadata());
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Craate a new compact DMesh3 with all of the ViRGiS metadata copied across
        /// </summary>
        /// <param name="dMesh">Source DMesh3</param>
        /// <returns>DMesh3</returns>
        public static DMesh3 Compactify(this DMesh3 dMesh)
        {
            DMesh3 mesh = new DMesh3(dMesh);

            //mesh.CompactCopy(dMesh);

            if (dMesh.HasMetadata)
            {
                string crs = dMesh.FindMetadata("CRS") as string;
                if (crs != null)
                {
                    mesh.AttachMetadata("CRS", crs);
                }
            }
            return(mesh);
        }
Ejemplo n.º 4
0
 public static bool IsFailureMesh(DMesh3 mesh)
 {
     return(mesh.FindMetadata("DMESHOP_FAILURE_MESH") != null);
 }