Ejemplo n.º 1
0
        public void SetGeomAsCenteredRing(List <Network> networks)
        {
            /*      . . ..
             *    .      ...
             *   .  .   X.  .
             *     .   .   .
             *     .. ..
             * .   . . .   .
             *
             */


            //1.) pick the highest power level observation with the best accuracy
            //2.) find the lowest power level reading with the best accuracy
            //calculate the distance, smooth it a bit, and draw a circle that size.



            //so... we have tons of observations for any given network.
            for (int i = 0; i < networks.Count; i++)
            {
                var net = networks[i];
                if (net.Observations.Count == 0)
                {
                    //TODO: Fix -- cell towers
                    continue;
                }

                var closest  = PickBestObservation(net, true);
                var furthest = PickBestObservation(net, false);
                if ((closest == null) || (furthest == null))
                {
                    continue;
                }

                var closestPT  = closest.GetPoint();
                var furthestPT = furthest.GetPoint();
                var dist       = closestPT.Distance(furthestPT);

                if (dist > 0.005)
                {
                    //too big
                    continue;
                }

                //draw circle.
                var fact = new NetTopologySuite.Utilities.GeometricShapeFactory(GeometryFactory.Default);
                var pt   = closestPT;
                var env  = new Envelope(pt.X + dist, pt.X - dist, pt.Y + dist, pt.Y - dist);

                fact.Envelope = env;

                fact.Centre    = closestPT.Coordinate;
                fact.NumPoints = 24;
                fact.Size      = dist;
                net.Geom       = fact.CreateCircle();
            }
        }
 private static IGeometry CreateCircle(Coordinate origin, double size, int nPts)
 {
     var gsf = new NetTopologySuite.Utilities.GeometricShapeFactory();
     gsf.Centre = origin;
     gsf.Size = size;
     gsf.NumPoints = nPts;
     var circle = gsf.CreateCircle();
     // Polygon gRect = gsf.createRectangle();
     // Geometry g = gRect.getExteriorRing();
     return circle;
 }
Ejemplo n.º 3
0
        private static IGeometry CreateCircle(Coordinate origin, double size, int nPts)
        {
            var gsf = new NetTopologySuite.Utilities.GeometricShapeFactory();

            gsf.Centre    = origin;
            gsf.Size      = size;
            gsf.NumPoints = nPts;
            var circle = gsf.CreateCircle();

            // Polygon gRect = gsf.createRectangle();
            // Geometry g = gRect.getExteriorRing();
            return(circle);
        }
        public void TestSerializable()
        {
            var fact = new GeometryFactory();
            var gsf = new NetTopologySuite.Utilities.GeometricShapeFactory(fact) ;
            gsf.Size = 250; 
            var g = (Geometry)gsf.CreateCircle();

            // serialize the object
            byte[] bytes = null;
            Assert.DoesNotThrow(() => bytes = SerializationUtility.Serialize(g));            

            // Assert that there was some serialized content produced
            Assert.IsNotNull(bytes, "There was no serialized packet produced");
            Assert.IsTrue(bytes.Length > 0, "There was no data in the serialized packet produced");

            // deserialize and check
            var gCopy = SerializationUtility.Deserialize<Geometry>(bytes);
            Assert.IsTrue(gCopy.EqualsExact(g), "The deserialized object does not match the original");
        }
        public void TestSerializable()
        {
            var fact = new GeometryFactory();
            var gsf  = new NetTopologySuite.Utilities.GeometricShapeFactory(fact);

            gsf.Size = 250;
            var g = (Geometry)gsf.CreateCircle();

            // serialize the object
            byte[] bytes = null;
            Assert.DoesNotThrow(() => bytes = SerializationUtility.Serialize(g));

            // Assert that there was some serialized content produced
            Assert.IsNotNull(bytes, "There was no serialized packet produced");
            Assert.IsTrue(bytes.Length > 0, "There was no data in the serialized packet produced");

            // deserialize and check
            var gCopy = SerializationUtility.Deserialize <Geometry>(bytes);

            Assert.IsTrue(gCopy.EqualsExact(g), "The deserialized object does not match the original");
        }