示例#1
0
        static PolygonResult STPolygonResult(Geometry instance, bool IsLine)
        {
            Geodesic g      = Geodesic.WGS84;
            var      line   = new GeographicLib.PolygonArea(g, IsLine);
            int      points = NTSGeographyWrapper.STNumPoinst(instance);

            for (int i = 1; i < points; i++)
            {
                Coordinate currentPoint = NTSGeographyWrapper.STPoints(instance)[i];
                line.AddPoint(currentPoint.Y, currentPoint.X);
            }
            PolygonResult r = line.Compute();

            return(r);
        }
示例#2
0
        ArrayList geoToArray(String geoType, Object geoInstance)
        {
            ArrayList ArrayOfPoints = new ArrayList();

            if (geoType.Equals("MultiPoint") || geoType.Equals("LineString"))
            {
                int points = NTSGeographyWrapper.STNumPoinst(geoInstance);
                for (int i = 1; i < points; i++)
                {
                    double[]   CurrentPoint = new double[2];
                    Coordinate currentPoint = NTSGeographyWrapper.STPoints(geoInstance)[i];
                    // lat y long
                    CurrentPoint[0] = currentPoint.X;
                    CurrentPoint[1] = currentPoint.Y;
                    ArrayOfPoints.Add(CurrentPoint);
                }
            }
            else if (geoType.Equals("Point"))
            {
                ArrayOfPoints.Add(NTSGeographyWrapper.Long(geoInstance));
                ArrayOfPoints.Add(NTSGeographyWrapper.Lat(geoInstance));
            }
            else if (geoType.Equals("Polygon"))
            {
                int rings = NTSGeographyWrapper.STNumRings(geoInstance);
                for (int j = 0; j < rings; j++)
                {
                    ArrayList RingArray   = new ArrayList();
                    object    currentRing = NTSGeographyWrapper.STRingN(geoInstance, j);
                    int       p           = NTSGeographyWrapper.STNumPoinst(currentRing);

                    for (int i = 0; i < p; i++)
                    {
                        double[]   CurrentPoint = new double[2];
                        Coordinate currentPoint = NTSGeographyWrapper.STPoints(currentRing)[i];
                        CurrentPoint[0] = currentPoint.X;
                        CurrentPoint[1] = currentPoint.Y;
                        RingArray.Add(CurrentPoint);
                    }
                    ArrayOfPoints.Add(RingArray);
                }
            }
            else if (geoType.Equals("MultiLineString"))
            {
                int geoms = NTSGeographyWrapper.STNumGeometries(geoInstance);
                for (int j = 0; j < geoms; j++)
                {
                    object currentgeom = NTSGeographyWrapper.STGeometryN(geoInstance, j);
                    ArrayOfPoints.Add(geoToArray("LineString", currentgeom));
                }
            }
            else if (geoType.Equals("MultiPolygon"))
            {
                int geoms = NTSGeographyWrapper.STNumGeometries(geoInstance);
                for (int j = 1; j < geoms; j++)
                {
                    object currentgeom = NTSGeographyWrapper.STGeometryN(geoInstance, j);
                    ArrayOfPoints.Add(geoToArray("Polygon", currentgeom));
                }
            }
            return(ArrayOfPoints);
        }