Exemplo n.º 1
0
            public override void ParseJson(DbGeographyGeoJsonConverter converter, Newtonsoft.Json.Linq.JArray array)
            {
                var targetCoordinateSystem = (converter as EpsgDbGeometryConverter).CoordinateSystem;
                //Cant convert if source dont have any coordinate system.
                if (!CoordinateSystem.HasValue ||  CoordinateSystem == targetCoordinateSystem)
                {
                    base.ParseJson(converter, array);
                    return;
                }

                Rings = new List<List<Position>>();
                var rings = array.ToObject<double[][][]>();

                var ringSizes = rings.Select(r => r.Length).ToArray();
                var coordinateLength = rings.First().GroupBy(c => c.Length).Single().Key;
                foreach (var ring in rings)
                {
                    var flat = ring.SelectMany(s => s).ToArray();

                    Reproject.ReprojectPoints(flat, null,
                     ProjectionInfo.FromEpsgCode(CoordinateSystem.Value), ProjectionInfo.FromEpsgCode(targetCoordinateSystem.Value), 0, ringSizes[0]);

                    var ringList = new List<Position>();
                    for (int i = 0; i < flat.Length; i += coordinateLength)
                        ringList.Add(new Position(flat.Skip(i).Take(coordinateLength).ToArray()));
                    Rings.Add(ringList);
                }
                CoordinateSystem = targetCoordinateSystem;
            }
Exemplo n.º 2
0
 private string getStringArray(Newtonsoft.Json.Linq.JArray arregloStr)
 {
     string ret = "";
     int cont = 0;
     foreach (string str in arregloStr.ToObject<string[]>())
     {
         ret += str + ", ";
         cont++;
         if (cont == 2)
             break;
     }
     ret = ret.Trim();
     ret = ret.TrimEnd(',');
     return ret;
 }
Exemplo n.º 3
0
 protected override void SetOptions(Newtonsoft.Json.Linq.JContainer o)
 {
     base.options = o.ToObject<PenTool.Options>();
 }
Exemplo n.º 4
0
 protected virtual void SetOptions(Newtonsoft.Json.Linq.JContainer o)
 {
     options = o.ToObject<Options>();
 }