Exemple #1
0
        /// <summary>
        /// get direction correction
        /// </summary>
        /// <returns>value of direction correction</returns>
        public Angle GetDirectionCorrection()
        {
            double Bm   = (Start.Latitude.Radians + End.Latitude.Radians) / 2;
            double eta2 = _sse * Math.Pow(Math.Cos(Bm), 2);
            double t    = Math.Tan(Bm);

            double cosB = Math.Cos(Bm);
            double V    = Math.Sqrt(1 + _sse * cosB * cosB);
            double Rm   = _a * Math.Sqrt(1 + _sse) / Math.Pow(V, 2);
            double Rm2  = Rm * Rm;

            GaussKrueger gauss = new GaussKrueger(new Ellipsoid(_a, 1 - Math.Sqrt(1 - _es)));

            gauss.Forward(Start.Latitude, Start.Longitude, out double x1, out double y1);
            gauss.Forward(End.Latitude, End.Longitude, out double x2, out double y2);

            //此处必须用自然坐标
            double ym = (GaussKrueger.GetNaturalCoord(y1) + GaussKrueger.GetNaturalCoord(y2)) / 2;

            // P199, (6-58)
            double delta = -(x2 - x1) * (2 * y1 + y2 - ym * ym * ym / Rm2) / (6 * Rm2) - eta2 * t * (y2 - y1) * ym * ym / (Rm * Rm2);

            return(Angle.FromRadians(delta));
        }
Exemple #2
0
        /// <summary><para>Die Funktion wandelt die Koordinaten eines <see cref="GeoUtility.GeoSystem.GaussKrueger"/>-Objektes
        /// in Längen/Breiten-Koordinaten eines <see cref="GeoUtility.GeoSystem.Geographic"/>-Objekts im Potsdam-Datum um.
        /// <para>Die Funktion ist nur für interne Berechnungen bestimmt.</para></para></summary>
        /// <remarks><para>
        /// Hintergründe zum Problem der Koordinatentransformationen sowie entsprechende  mathematische
        /// Formeln können den einschlägigen Fachbüchern oder dem Internet entnommen werden.<p />
        /// Quellen:
        /// Bundesamt für Kartographie und Geodäsie<br />
        /// <a href="http://www.bkg.bund.de" target="_blank">http://www.bkg.bund.de</a><br />
        /// <a href="http://crs.bkg.bund.de" target="_blank">http://crs.bkg.bund.de</a><br />
        /// </para></remarks>
        ///
        /// <param name="gauss">Ein <see cref="GeoUtility.GeoSystem.GaussKrueger"/>-Objekt-</param>
        /// <returns>Ein <see cref="GeoUtility.GeoSystem.Geographic"/>-Objekt (<see cref="GeoUtility.GeoSystem.Helper.GeoDatum.Potsdam">Potsdam-Datum</see>).</returns>
        public static Geographic GKPOD(GaussKrueger gauss)
        {
            double rechts = gauss.East;
            double hoch   = gauss.North;

            // Koeffizienten für Länge Meridianbogen
            double koeff0 = POL * (Math.PI / 180) * (1 - 3 * EXZENT2 / 4 + 45 * EXZENT4 / 64 - 175 * EXZENT6 / 256 + 11025 * EXZENT8 / 16384);
            double koeff2 = (180 / Math.PI) * (3 * EXZENT2 / 8 - 3 * EXZENT4 / 16 + 213 * EXZENT6 / 2048 - 255 * EXZENT8 / 4096);
            double koeff4 = (180 / Math.PI) * (21 * EXZENT4 / 256 - 21 * EXZENT6 / 256 + 533 * EXZENT8 / 8192);
            double koeff6 = (180 / Math.PI) * (151 * EXZENT6 / 6144 - 453 * EXZENT8 / 12288);

            // Geogr. Breite (Rad)
            double sig       = hoch / koeff0;
            double sigRad    = sig * Math.PI / 180;
            double fbreite   = sig + koeff2 * Math.Sin(2 * sigRad) + koeff4 * Math.Sin(4 * sigRad) + koeff6 * Math.Sin(6 * sigRad);
            double breiteRad = fbreite * Math.PI / 180;

            double tangens1 = Math.Tan(breiteRad);
            double tangens2 = Math.Pow(tangens1, 2);
            double tangens4 = Math.Pow(tangens1, 4);
            double cosinus1 = Math.Cos(breiteRad);
            double cosinus2 = Math.Pow(cosinus1, 2);

            double eta = EXZENT2 * cosinus2;

            // Querkrümmung
            double qkhm1 = POL / Math.Sqrt(1 + eta);
            double qkhm2 = Math.Pow(qkhm1, 2);
            double qkhm3 = Math.Pow(qkhm1, 3);
            double qkhm4 = Math.Pow(qkhm1, 4);
            double qkhm5 = Math.Pow(qkhm1, 5);
            double qkhm6 = Math.Pow(qkhm1, 6);

            // Differenz zum Bezugsmeridian
            int    kfakt    = (int)(rechts / 1E+06);
            int    merid    = kfakt * 3;
            double dlaenge1 = rechts - (kfakt * 1E+06 + 500000);
            double dlaenge2 = Math.Pow(dlaenge1, 2);
            double dlaenge3 = Math.Pow(dlaenge1, 3);
            double dlaenge4 = Math.Pow(dlaenge1, 4);
            double dlaenge5 = Math.Pow(dlaenge1, 5);
            double dlaenge6 = Math.Pow(dlaenge1, 6);

            // Faktor für Berechnung Breite
            double bfakt2 = -tangens1 * (1 + eta) / (2 * qkhm2);
            double bfakt4 = tangens1 * (5 + 3 * tangens2 + 6 * eta * (1 - tangens2)) / (24 * qkhm4);
            double bfakt6 = -tangens1 * (61 + 90 * tangens2 + 45 * tangens4) / (720 * qkhm6);

            // Faktor für Berechnung Länge
            double lfakt1 = 1 / (qkhm1 * cosinus1);
            double lfakt3 = -(1 + 2 * tangens2 + eta) / (6 * qkhm3 * cosinus1);
            double lfakt5 = (5 + 28 * tangens2 + 24 * tangens4) / (120 * qkhm5 * cosinus1);

            // Geographische Länge und Breite Potsdam
            double geoBreite = fbreite + (180 / Math.PI) * (bfakt2 * dlaenge2 + bfakt4 * dlaenge4 + bfakt6 * dlaenge6);
            double geoLaenge = merid + (180 / Math.PI) * (lfakt1 * dlaenge1 + lfakt3 * dlaenge3 + lfakt5 * dlaenge5);

            if (geoLaenge < MIN_OST || geoLaenge > MAX_OST || geoBreite < MIN_NORD || geoBreite > MAX_NORD)
            {
                throw new ArgumentException("ERROR_GK_OUT_OF_RANGE");
            }

            return(new Geographic(geoLaenge, geoBreite, GeoDatum.Potsdam));
        }
        /// <summary><para>Die Funktion wandelt die Koordinaten eines <see cref="GeoUtility.GeoSystem.GaussKrueger"/>-Objektes 
        /// in Längen/Breiten-Koordinaten eines <see cref="GeoUtility.GeoSystem.Geographic"/>-Objekts im Potsdam-Datum um. 
        /// <para>Die Funktion ist nur für interne Berechnungen bestimmt.</para></para></summary>
        /// <remarks><para>
        /// Hintergründe zum Problem der Koordinatentransformationen sowie entsprechende  mathematische 
        /// Formeln können den einschlägigen Fachbüchern oder dem Internet entnommen werden.<p />
        /// Quellen: 
        /// Bundesamt für Kartographie und Geodäsie<br />
        /// <a href="http://www.bkg.bund.de" target="_blank">http://www.bkg.bund.de</a><br />
        /// <a href="http://crs.bkg.bund.de" target="_blank">http://crs.bkg.bund.de</a><br />
        /// </para></remarks>
        /// 
        /// <param name="gauss">Ein <see cref="GeoUtility.GeoSystem.GaussKrueger"/>-Objekt-</param>
        /// <returns>Ein <see cref="GeoUtility.GeoSystem.Geographic"/>-Objekt (<see cref="GeoUtility.GeoSystem.Helper.GeoDatum.Potsdam">Potsdam-Datum</see>).</returns>
        internal Geographic GKPOD(GaussKrueger gauss)
        {

            double rechts = gauss.East;
            double hoch = gauss.North;

            // Koeffizienten für Länge Meridianbogen
            double koeff0 = POL * (Math.PI / 180) * (1 - 3 * EXZENT2 / 4 + 45 * EXZENT4 / 64 - 175 * EXZENT6 / 256 + 11025 * EXZENT8 / 16384);
            double koeff2 = (180 / Math.PI) * (3 * EXZENT2 / 8 - 3 * EXZENT4 / 16 + 213 * EXZENT6 / 2048 - 255 * EXZENT8 / 4096);
            double koeff4 = (180 / Math.PI) * (21 * EXZENT4 / 256 - 21 * EXZENT6 / 256 + 533 * EXZENT8 / 8192);
            double koeff6 = (180 / Math.PI) * (151 * EXZENT6 / 6144 - 453 * EXZENT8 / 12288);

            // Geogr. Breite (Rad)
            double sig = hoch / koeff0;
            double sigRad = sig * Math.PI / 180;
            double fbreite = sig + koeff2 * Math.Sin(2 * sigRad) + koeff4 * Math.Sin(4 * sigRad) + koeff6 * Math.Sin(6 * sigRad);
            double breiteRad = fbreite * Math.PI / 180;

            double tangens1 = Math.Tan(breiteRad);
            double tangens2 = Math.Pow(tangens1, 2);
            double tangens4 = Math.Pow(tangens1, 4);
            double cosinus1 = Math.Cos(breiteRad);
            double cosinus2 = Math.Pow(cosinus1, 2);

            double eta = EXZENT2 * cosinus2;
            
            // Querkrümmung
            double qkhm1 = POL / Math.Sqrt(1 + eta);
            double qkhm2 = Math.Pow(qkhm1, 2);
            double qkhm3 = Math.Pow(qkhm1, 3);
            double qkhm4 = Math.Pow(qkhm1, 4);
            double qkhm5 = Math.Pow(qkhm1, 5);
            double qkhm6 = Math.Pow(qkhm1, 6);

            // Differenz zum Bezugsmeridian
            int kfakt = (int)(rechts / 1E+06);
            int merid = kfakt * 3;
            double dlaenge1 = rechts - (kfakt * 1E+06 + 500000);
            double dlaenge2 = Math.Pow(dlaenge1, 2);
            double dlaenge3 = Math.Pow(dlaenge1, 3);
            double dlaenge4 = Math.Pow(dlaenge1, 4);
            double dlaenge5 = Math.Pow(dlaenge1, 5);
            double dlaenge6 = Math.Pow(dlaenge1, 6);

            // Faktor für Berechnung Breite
            double bfakt2 = -tangens1 * (1 + eta) / (2 * qkhm2);
            double bfakt4 = tangens1 * (5 + 3 * tangens2 + 6 * eta * (1 - tangens2)) / (24 * qkhm4);
            double bfakt6 = -tangens1 * (61 + 90 * tangens2 + 45 * tangens4) / (720 * qkhm6);

            // Faktor für Berechnung Länge
            double lfakt1 = 1 / (qkhm1 * cosinus1);
            double lfakt3 = -(1 + 2 * tangens2 + eta) / (6 * qkhm3 * cosinus1);
            double lfakt5 = (5 + 28 * tangens2 + 24 * tangens4) / (120 * qkhm5 * cosinus1);

            // Geographische Länge und Breite Potsdam
            double geoBreite = fbreite + (180 / Math.PI) * (bfakt2 * dlaenge2 + bfakt4 * dlaenge4 + bfakt6 * dlaenge6);
            double geoLaenge = merid + (180 / Math.PI) * (lfakt1 * dlaenge1 + lfakt3 * dlaenge3 + lfakt5 * dlaenge5);

            if (geoLaenge < MIN_OST || geoLaenge > MAX_OST || geoBreite < MIN_NORD || geoBreite > MAX_NORD)
            {
                throw new ErrorProvider.GeoException(new ErrorProvider.ErrorMessage("ERROR_GK_OUT_OF_RANGE"));
            }

            return new Geographic(geoLaenge, geoBreite, GeoDatum.Potsdam);
        }
Exemple #4
0
        Operation IParser.Parse(string[] lines)
        {
            Operation         operation = new Operation();
            OperationResource last      = new OperationResource();

            lines = Utilities.Trim(lines);
            CurrentSection   section      = CurrentSection.AHeader;
            bool             keywordsOnly = true;
            NumberFormatInfo nfi          = new NumberFormatInfo {
                NumberDecimalSeparator = "."
            };

            for (int i = 0; i < lines.Length; i++)
            {
                try
                {
                    string line = lines[i];
                    if (line.Length == 0)
                    {
                        continue;
                    }

                    // Try to parse the header and extract date and time if possible
                    operation.Timestamp = ParserUtility.ReadFaxTimestamp(line, operation.Timestamp);



                    if (GetSection(line.Trim(), ref section, ref keywordsOnly))
                    {
                        continue;
                    }

                    string msg    = line;
                    string prefix = "";

                    // Make the keyword check - or not (depends on the section we are in; see above)
                    if (keywordsOnly)
                    {
                        string keyword;
                        if (!ParserUtility.StartsWithKeyword(line, Keywords, out keyword))
                        {
                            continue;
                        }

                        int x = line.IndexOf(':');
                        if (x == -1)
                        {
                            // If there is no colon found (may happen occasionally) then simply remove the length of the keyword from the beginning
                            prefix = keyword;
                            msg    = line.Remove(0, prefix.Length).Trim();
                        }
                        else
                        {
                            prefix = line.Substring(0, x);
                            msg    = line.Substring(x + 1).Trim();
                        }

                        prefix = prefix.Trim().ToUpperInvariant();
                    }

                    // Parse each section
                    switch (section)
                    {
                    case CurrentSection.AHeader:
                    {
                        switch (prefix)
                        {
                        case "ABSENDER":
                            operation.CustomData["Absender"] = msg;
                            break;

                        case "TERMIN":
                            operation.CustomData["Termin"] = msg;
                            break;

                        case "EINSATZN.":
                            operation.OperationNumber = msg;
                            break;
                        }
                    }
                    break;

                    case CurrentSection.BMitteiler:
                    {
                        // This switch would not be necessary in this section (there is only "Name")...
                        switch (prefix)
                        {
                        case "NAME":
                            operation.Messenger = msg;
                            break;
                        }
                    }
                    break;

                    case CurrentSection.CEinsatzort:
                    {
                        switch (prefix)
                        {
                        case "STRAßE":
                        {
                            operation.Einsatzort.Street = msg;
                        }
                        break;

                        case "HAUS-NR.":
                        {
                            operation.Einsatzort.StreetNumber = msg;
                        }
                        break;

                        case "ABSCHNITT":
                        {
                            operation.Einsatzort.Intersection = msg;
                        }
                        break;

                        case "ORTSTEIL":
                        {
                            operation.CustomData["Einsatzort Ortsteil"] = msg;
                        }
                        break;

                        case "ORT":
                        {
                            operation.Einsatzort.ZipCode = ParserUtility.ReadZipCodeFromCity(msg);
                            if (string.IsNullOrWhiteSpace(operation.Einsatzort.ZipCode))
                            {
                                Logger.Instance.LogFormat(LogType.Warning, this, "Could not find a zip code for city '{0}'. Route planning may fail or yield wrong results!", operation.Einsatzort.City);
                            }

                            operation.Einsatzort.City = msg.Remove(0, operation.Einsatzort.ZipCode.Length).Trim();

                            // The City-text often contains a dash after which the administrative city appears multiple times (like "City A - City A City A").
                            // However we can (at least with google maps) omit this information without problems!
                            int dashIndex = operation.Einsatzort.City.IndexOf(" - ");
                            if (dashIndex != -1)
                            {
                                // Ignore everything after the dash
                                operation.Einsatzort.City = operation.Einsatzort.City.Substring(0, dashIndex).Trim();
                            }
                        }
                        break;

                        case "KOORDINATE":

                            Regex r       = new Regex(@"\d+");
                            var   matches = r.Matches(line);
                            if (matches.Count > 2)
                            {
                                int          rechts = Convert.ToInt32(matches[0].Value);
                                int          hoch   = Convert.ToInt32(matches[1].Value);
                                GaussKrueger gauss  = new GaussKrueger(rechts, hoch);
                                Geographic   geo    = (Geographic)gauss;
                                operation.Einsatzort.GeoLatitude  = geo.Latitude;
                                operation.Einsatzort.GeoLongitude = geo.Longitude;
                            }
                            break;

                        case "OBJEKT":
                            operation.Einsatzort.Property = msg;
                            break;

                        case "EINSATZPLAN":
                            operation.OperationPlan = msg;
                            break;

                        case "STATION":
                            operation.CustomData["Einsatzort Station"] = msg;
                            break;

                        case "SCHLAGWORT":
                            operation.Keywords.Keyword = msg;
                            break;

                        case "STICHWORT B":
                            operation.Keywords.B = msg;
                            break;

                        case "STICHWORT T":
                            operation.Keywords.T = msg;
                            break;

                        case "STICHWORT S":
                            operation.Keywords.S = msg;
                            break;

                        case "STICHWORT I":
                            operation.CustomData["Stichwort I"] = msg;
                            break;

                        case "STICHWORT R":
                            operation.Keywords.R = msg;
                            break;
                        }
                    }
                    break;

                    case CurrentSection.FEinsatzmittel:
                    {
                        switch (prefix)
                        {
                        case "NAME":
                            last.FullName = msg.Trim();
                            break;

                        case "AUSSTATTUNG":
                            // Only add to requested equipment if there is some text,
                            // otherwise the whole vehicle is the requested equipment
                            if (!string.IsNullOrWhiteSpace(msg))
                            {
                                last.RequestedEquipment.Add(msg);
                            }
                            // This line will end the construction of this resource. Add it to the list and go to the next.
                            operation.Resources.Add(last);

                            last = new OperationResource();
                            break;
                        }
                    }
                    break;

                    case CurrentSection.GBemerkung:
                    {
                        // Append with newline at the end in case that the message spans more than one line
                        operation.Comment = operation.Comment.AppendLine(msg);
                    }
                    break;

                    case CurrentSection.HFooter:
                        // The footer can be ignored completely.
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Warning, this, "Error while parsing line '{0}'. The error message was: {1}", i, ex.Message);
                }
            }
            return(operation);
        }
Exemple #5
0
        public void Execute(params object[] list)
        {
            string addr = (string)list [0];

            if (addr.Substring(0, 5) == "COORD")
            {
                addr = addr.Substring(addr.IndexOf(":") + 1);
                FeuerwehrCloud.Helper.Logger.WriteLine("|  + [GeoCoder] *** Converting Gauss-Krüger to Latitude/Longitude: " + addr);
                GaussKrueger gauss = new GaussKrueger(int.Parse(addr.Substring(0, addr.IndexOf(" ")).Trim()), int.Parse(addr.Substring(addr.IndexOf(" ") + 1).Trim()));
                MGRS         mgrs  = (MGRS)gauss;
                Geographic   geo   = (Geographic)mgrs;
                double       lon   = geo.Longitude;
                double       lat   = geo.Latitude;

                string key            = "AsSta3yGavJt7O8i-SokTyANtvF1HfBoPK5GdD_xgl4ul6ZBmBB3Ru7gX7pof0_T";
                Uri    geocodeRequest = new Uri(string.Format("http://dev.virtualearth.net/REST/v1/Locations?q={0}&key={1}", addr, key));
                System.Collections.Generic.Dictionary <string, string> Result;
                Result = new System.Collections.Generic.Dictionary <string, string> ();
                System.Net.WebClient WCC = new WebClient();
                Result.Add("lat", (System.Math.Round(lat, 5)).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
                Result.Add("lng", (System.Math.Round(lon, 5)).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
                try {
                    System.Net.ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => {
                        return(true);
                    };
                    System.Net.WebClient WC = new System.Net.WebClient();
                    FeuerwehrCloud.Helper.Logger.WriteLine("|  + [GeoCoder] *** downloading map...");
                    WC.DownloadFile("http://dev.virtualearth.net/REST/V1/Imagery/Map/AerialWithLabels/" + (lat).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + "," + (lon).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + "/16?pp=" + (lat).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + "," + (lon).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + ";10;&mapSize=600,700&mapLayer=TrafficFlow&key=AsSta3yGavJt7O8i-SokTyANtvF1HfBoPK5GdD_xgl4ul6ZBmBB3Ru7gX7pof0_T", "/tmp/map.jpg");
                    //WC.DownloadFile("https://maps.googleapis.com/maps/api/staticmap?center="+(lat).ToString (System.Globalization.CultureInfo.InvariantCulture.NumberFormat)+","+(lon ).ToString (System.Globalization.CultureInfo.InvariantCulture.NumberFormat)+"&zoom=13&scale=2&size=400x900&maptype=roadmap&format=png&visual_refresh=true&markers=size:big%7Ccolor:red%7Clabel:Einsatzort%7C"+(lat ).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat)+","+(lon ).ToString (System.Globalization.CultureInfo.InvariantCulture.NumberFormat),"/tmp/map.png");
                    string XFile = System.IO.File.ReadAllText("web/" + ((string)list [1]).Replace(" ", "_") + ".xml");
                    XFile = XFile.Replace("<Property name=\"Tag\">MAP</Property>", "<Property name=\"Tag\">MAP</Property>\r\n      <Property name=\"Image\">\r\n        <Binary>" + System.Convert.ToBase64String(System.IO.File.ReadAllBytes("/tmp/map.jpg")) + "</Binary>\r\n</Property>");
                    FeuerwehrCloud.Helper.Logger.WriteLine("|  + [GeoCoder] *** put map to panel-xml...");
                    System.IO.File.WriteAllText("web/panel.xml", XFile);
                    System.IO.File.WriteAllText("web/" + ((string)list [1]).Replace(" ", "_") + ".xml", XFile);
                } catch (Exception exx) {
                    FeuerwehrCloud.Helper.Logger.WriteLine(exx.ToString());
                }
                RaiseFinish("text", Result);
            }
            else
            {
                FeuerwehrCloud.Helper.Logger.WriteLine("|  + [GeoCoder] *** Trying to get coordinates from: " + addr);
                try {
                    System.Collections.Generic.Dictionary <string, string> Result;
                                        #if GOOGLE
                    Geocoding.Address[] addresses = GeC.Geocode((string)list[0]).ToArray();
                    Result = new System.Collections.Generic.Dictionary <string, string> ();
                    Result.Add("lat", (addresses [0].Coordinates.Latitude).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
                    Result.Add("lng", (addresses [0].Coordinates.Longitude).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
                    try {
                        System.Net.ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => { return(true); };
                        System.Net.WebClient WC = new System.Net.WebClient();
                        WC.DownloadFile("https://maps.googleapis.com/maps/api/staticmap?center=" + (addresses [0].Coordinates.Latitude).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + "," + (addresses [0].Coordinates.Longitude).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + "&zoom=13&scale=2&size=400x900&maptype=roadmap&format=png&visual_refresh=true&markers=size:big%7Ccolor:red%7Clabel:Einsatzort%7C" + (addresses [0].Coordinates.Latitude).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + "," + (addresses [0].Coordinates.Longitude).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat), "/tmp/map.png");
                        string XFile = System.IO.File.ReadAllText("/FeuerwehrCloud/DEIVA/panel.xml");
                        XFile = XFile.Replace("<Property name=\"Tag\">MAP</Property>", "<Property name=\"Tag\">MAP</Property>\r\n      <Property name=\"Image\">\r\n        <Binary>" + System.Convert.ToBase64String(System.IO.File.ReadAllBytes("/tmp/map.png")) + "</Binary>\r\n</Property>");
                        System.IO.File.WriteAllText("/FeuerwehrCloud/DEIVA/panel.xml", XFile);
                    } catch (Exception ex) {
                        FeuerwehrCloud.Helper.Logger.WriteLine(ex.ToString());
                    }
                    RaiseFinish("text", Result);
                                        #else
                    // StaticMap with Routes!
                    //http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Routes?mapSize=800,800&wp.0=Sonnenstr.3,Rosenheim;64;1&wp.1=Hoffeldstr.10,Rosenheim;66;2&key=AsSta3yGavJt7O8i-SokTyANtvF1HfBoPK5GdD_xgl4ul6ZBmBB3Ru7gX7pof0_T

                    string key            = "AsSta3yGavJt7O8i-SokTyANtvF1HfBoPK5GdD_xgl4ul6ZBmBB3Ru7gX7pof0_T";
                    Uri    geocodeRequest = new Uri(string.Format("http://dev.virtualearth.net/REST/v1/Locations?q={0}&key={1}", addr, key));
                    Result = new System.Collections.Generic.Dictionary <string, string> ();
                    System.Net.WebClient WCC = new WebClient();
                    try {
                        string str = WCC.DownloadString(geocodeRequest);
                        if (str.IndexOf("\"Point\",\"coordinates\":") > -1)
                        {
                            FeuerwehrCloud.Helper.Logger.WriteLine("|  + [GeoCoder] *** Address found!");
                            dynamic jsonDe = JsonConvert.DeserializeObject(str);
                            float   lat    = jsonDe.resourceSets [0].resources [0].point.coordinates [0];
                            float   lon    = jsonDe.resourceSets [0].resources [0].point.coordinates [1];
                            Result.Add("lat", (System.Math.Round(lat, 5)).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
                            Result.Add("lng", (System.Math.Round(lon, 5)).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
                            try {
                                System.Net.ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => {
                                    return(true);
                                };
                                System.Net.WebClient WC = new System.Net.WebClient();
                                FeuerwehrCloud.Helper.Logger.WriteLine("|  + [GeoCoder] *** downloading map...");
                                //WC.DownloadFile ("http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/" + (lat).ToString (System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + "," + (lon).ToString (System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + "/14?pp=" + (lat).ToString (System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + "," + (lon).ToString (System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + ";47;!&mapSize=400,700&mapLayer=TrafficFlow&key=AsSta3yGavJt7O8i-SokTyANtvF1HfBoPK5GdD_xgl4ul6ZBmBB3Ru7gX7pof0_T", "/tmp/map.jpg");
                                WC.DownloadFile("http://dev.virtualearth.net/REST/V1/Imagery/Map/AerialWithLabels/" + (lat).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + "," + (lon).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + "/16?pp=" + (lat).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + "," + (lon).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + ";10;&mapSize=500,700&mapLayer=TrafficFlow&key=AsSta3yGavJt7O8i-SokTyANtvF1HfBoPK5GdD_xgl4ul6ZBmBB3Ru7gX7pof0_T", "/tmp/map.jpg");
                                //WC.DownloadFile("https://maps.googleapis.com/maps/api/staticmap?center="+(lat).ToString (System.Globalization.CultureInfo.InvariantCulture.NumberFormat)+","+(lon ).ToString (System.Globalization.CultureInfo.InvariantCulture.NumberFormat)+"&zoom=13&scale=2&size=400x900&maptype=roadmap&format=png&visual_refresh=true&markers=size:big%7Ccolor:red%7Clabel:Einsatzort%7C"+(lat ).ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat)+","+(lon ).ToString (System.Globalization.CultureInfo.InvariantCulture.NumberFormat),"/tmp/map.png");
                                string XFile = System.IO.File.ReadAllText("web/panel.xml");
                                XFile = XFile.Replace("<Property name=\"Tag\">MAP</Property>", "<Property name=\"Tag\">MAP</Property>\r\n      <Property name=\"Image\">\r\n        <Binary>" + System.Convert.ToBase64String(System.IO.File.ReadAllBytes("/tmp/map.jpg")) + "</Binary>\r\n</Property>");
                                FeuerwehrCloud.Helper.Logger.WriteLine("|  + [GeoCoder] *** put map to panel-xml...");
                                System.IO.File.WriteAllText("web/panel.xml", XFile);
                            } catch (Exception exx) {
                                FeuerwehrCloud.Helper.Logger.WriteLine(exx.ToString());
                            }
                            FeuerwehrCloud.Helper.Logger.WriteLine("|  + [GeoCoder] *** done...!");
                            RaiseFinish("text", Result);
                        }
                        else
                        {
                            FeuerwehrCloud.Helper.Logger.WriteLine("|  + [GeoCoder] *** Address not found ... :/");
                            FeuerwehrCloud.Helper.Logger.WriteLine(str);
                            // Keine Koordinaten gefunden... :/
                        }
                    } catch (Exception ex) {
                        if (ex.GetType().ToString() == "System.Net.WebException")
                        {
                            if (ex.Message == "NameResolutionFailure")
                            {
                                // PANIC! We don't have internet!!!!
                            }
                        }
                        FeuerwehrCloud.Helper.Logger.WriteLine("|  + [GeoCoder] *** Exception... :/");
                        FeuerwehrCloud.Helper.Logger.WriteLine(FeuerwehrCloud.Helper.Helper.GetExceptionDescription(ex));
                    }
                                        #endif
                } catch (Exception ex) {
                    FeuerwehrCloud.Helper.Logger.WriteLine(FeuerwehrCloud.Helper.Helper.GetExceptionDescription(ex));
                }
            }
        }
Exemple #6
0
        public static Geographic FromGaussKrueger(double east, double north)
        {
            GaussKrueger gauss = new GaussKrueger(east, north);

            return((Geographic)gauss);
        }