Ejemplo n.º 1
0
        public static bool IsClockwise(System.Collections.Generic.List <OSM.API.v0_6.GeoPoint> poly)
        {
            decimal sum = 0;

            for (int i = 0; i < poly.Count - 1; i++)
            {
                OSM.API.v0_6.GeoPoint cur = poly[i], next = poly[i + 1];
                sum += (next.Latitude - cur.Latitude) * (next.Longitude + cur.Longitude);
            } // Next i

            return(sum > 0);
        } // End Function isClockwise
Ejemplo n.º 2
0
        // http://www.rotefabrik.free.fr/concave_hull/


        public static System.Collections.Generic.List <System.Collections.Generic.List <OSM.API.v0_6.GeoPoint> > FineGrainedHullPoints(
            System.Collections.Generic.List <System.Collections.Generic.List <OSM.API.v0_6.GeoPoint> > ls, int numPointsOnLine
            )
        {
            System.Collections.Generic.List <System.Collections.Generic.List <OSM.API.v0_6.GeoPoint> > ls2 = new System.Collections.Generic.List <System.Collections.Generic.List <OSM.API.v0_6.GeoPoint> >();

            foreach (System.Collections.Generic.List <OSM.API.v0_6.GeoPoint> thisList in ls)
            {
                System.Collections.Generic.List <OSM.API.v0_6.GeoPoint> newList =
                    new System.Collections.Generic.List <OSM.API.v0_6.GeoPoint>();

                for (int i = 0; i < thisList.Count; ++i)
                {
                    OSM.API.v0_6.GeoPoint thisPoint = thisList[i];
                    newList.Add(thisPoint);

                    if (i < thisList.Count - 1)
                    {
                        OSM.API.v0_6.GeoPoint nextPoint = thisList[i + 1];

                        decimal deltaX = nextPoint.Latitude - thisPoint.Latitude;
                        decimal deltaY = nextPoint.Longitude - thisPoint.Longitude;

                        deltaX = deltaX / numPointsOnLine;
                        deltaY = deltaY / numPointsOnLine;

                        for (int j = 0; j < numPointsOnLine; ++j)
                        {
                            var newPoint = new OSM.API.v0_6.GeoPoint(thisPoint.Latitude + j * deltaX, thisPoint.Longitude + j * deltaY);
                            newList.Add(newPoint);
                        }
                    }
                }

                ls2.Add(newList);
            }

            return(ls2);
        }