Ejemplo n.º 1
0
        public virtual void TestOGCMultiPoint()
        {
            com.epl.geometry.MultiPoint mp = new com.epl.geometry.MultiPoint();
            mp.Add(10.0, 20.0);
            mp.Add(20.0, 30.0);
            com.epl.geometry.ogc.OGCMultiPoint ogcMultiPoint = new com.epl.geometry.ogc.OGCMultiPoint(mp, null);
            string result = ogcMultiPoint.AsGeoJson();

            NUnit.Framework.Assert.AreEqual("{\"type\":\"MultiPoint\",\"coordinates\":[[10,20],[20,30]],\"crs\":null}", result);
        }
Ejemplo n.º 2
0
        public static com.epl.geometry.ogc.OGCGeometry CreateFromOGCStructure(com.epl.geometry.OGCStructure ogcStructure, com.epl.geometry.SpatialReference sr)
        {
            System.Collections.Generic.List <com.epl.geometry.ogc.OGCConcreteGeometryCollection> collectionStack = new System.Collections.Generic.List <com.epl.geometry.ogc.OGCConcreteGeometryCollection>(0);
            System.Collections.Generic.List <com.epl.geometry.OGCStructure> structureStack = new System.Collections.Generic.List <com.epl.geometry.OGCStructure>(0);
            System.Collections.Generic.List <int> indices           = new System.Collections.Generic.List <int>(0);
            com.epl.geometry.ogc.OGCGeometry[]    geometries        = new com.epl.geometry.ogc.OGCGeometry[1];
            com.epl.geometry.ogc.OGCConcreteGeometryCollection root = new com.epl.geometry.ogc.OGCConcreteGeometryCollection(java.util.Arrays.AsList(geometries), sr);
            structureStack.Add(ogcStructure);
            collectionStack.Add(root);
            indices.Add(0);
            while (!structureStack.IsEmpty())
            {
                com.epl.geometry.OGCStructure lastStructure = structureStack[structureStack.Count - 1];
                if (indices[indices.Count - 1] == lastStructure.m_structures.Count)
                {
                    structureStack.Remove(structureStack.Count - 1);
                    collectionStack.Remove(collectionStack.Count - 1);
                    indices.Remove(indices.Count - 1);
                    continue;
                }
                com.epl.geometry.ogc.OGCConcreteGeometryCollection lastCollection = collectionStack[collectionStack.Count - 1];
                com.epl.geometry.ogc.OGCGeometry g;
                int i    = indices[indices.Count - 1];
                int type = lastStructure.m_structures[i].m_type;
                switch (type)
                {
                case 1:
                {
                    g = new com.epl.geometry.ogc.OGCPoint((com.epl.geometry.Point)lastStructure.m_structures[i].m_geometry, sr);
                    lastCollection.geometries[i] = g;
                    indices[indices.Count - 1]   = i + 1;
                    break;
                }

                case 2:
                {
                    g = new com.epl.geometry.ogc.OGCLineString((com.epl.geometry.Polyline)lastStructure.m_structures[i].m_geometry, 0, sr);
                    lastCollection.geometries[i] = g;
                    indices[indices.Count - 1]   = i + 1;
                    break;
                }

                case 3:
                {
                    g = new com.epl.geometry.ogc.OGCPolygon((com.epl.geometry.Polygon)lastStructure.m_structures[i].m_geometry, 0, sr);
                    lastCollection.geometries[i] = g;
                    indices[indices.Count - 1]   = i + 1;
                    break;
                }

                case 4:
                {
                    g = new com.epl.geometry.ogc.OGCMultiPoint((com.epl.geometry.MultiPoint)lastStructure.m_structures[i].m_geometry, sr);
                    lastCollection.geometries[i] = g;
                    indices[indices.Count - 1]   = i + 1;
                    break;
                }

                case 5:
                {
                    g = new com.epl.geometry.ogc.OGCMultiLineString((com.epl.geometry.Polyline)lastStructure.m_structures[i].m_geometry, sr);
                    lastCollection.geometries[i] = g;
                    indices[indices.Count - 1]   = i + 1;
                    break;
                }

                case 6:
                {
                    g = new com.epl.geometry.ogc.OGCMultiPolygon((com.epl.geometry.Polygon)lastStructure.m_structures[i].m_geometry, sr);
                    lastCollection.geometries[i] = g;
                    indices[indices.Count - 1]   = i + 1;
                    break;
                }

                case 7:
                {
                    geometries = new com.epl.geometry.ogc.OGCGeometry[lastStructure.m_structures[i].m_structures.Count];
                    g          = new com.epl.geometry.ogc.OGCConcreteGeometryCollection(java.util.Arrays.AsList(geometries), sr);
                    lastCollection.geometries[i] = g;
                    indices[indices.Count - 1]   = i + 1;
                    structureStack.Add(lastStructure.m_structures[i]);
                    collectionStack.Add((com.epl.geometry.ogc.OGCConcreteGeometryCollection)g);
                    indices.Add(0);
                    break;
                }

                default:
                {
                    throw new System.NotSupportedException();
                }
                }
            }
            return(root.geometries[0]);
        }