Ejemplo n.º 1
0
        public void ReserveOkPartMove(MapSection mapSection)
        {
            try
            {
                int sectionIndex = MovingGuide.GuideSectionIds.FindIndex(x => x.Trim() == mapSection.Id.Trim());
                if (sectionIndex < 0)
                {
                    OnLogErrorEvent?.Invoke(this, new MessageHandlerArgs()
                    {
                        ClassMethodName = GetType().Name + ":" + System.Reflection.MethodBase.GetCurrentMethod().Name,
                        Message         = $"ReserveOkPartMove fail.[{mapSection.Id.Trim()}].[{MovingGuide.GuideSectionIds.GetJsonInfo()}]"
                    });

                    return;
                }
                MapAddress address = MapInfo.addressMap[MovingGuide.GuideAddressIds[sectionIndex + 1]];

                PositionArgs positionArgs = new PositionArgs()
                {
                    EnumLocalArrival = sectionIndex == MovingGuide.GuideSectionIds.Count - 1 ? EnumLocalArrival.EndArrival : EnumLocalArrival.Arrival,
                    MapPosition      = address.Position
                };

                FakeMoveArrivalQueue.Enqueue(positionArgs);
            }
            catch (Exception ex)
            {
                OnLogErrorEvent?.Invoke(this, new MessageHandlerArgs()
                {
                    ClassMethodName = GetType().Name + ":" + System.Reflection.MethodBase.GetCurrentMethod().Name,
                    Message         = ex.Message
                });
            }
        }
Ejemplo n.º 2
0
        public bool GetMovingAngleAfterRTurn(AGVTurnParameter turn, MapAddress start, MapAddress end, ref double newAGVMovingAngle, ref string errorMessage)
        {
            double rTurnSectionAngle = ComputeAngle(start.AGVPosition, end.AGVPosition);
            double agvGoAngle        = start.AGVPosition.Angle;
            bool   dirFlag           = true;

            if (Math.Abs(GetCurrectAngle(agvGoAngle - rTurnSectionAngle)) >= 90)
            {
                dirFlag    = false;
                agvGoAngle = GetCurrectAngle(agvGoAngle - 180);
            }

            double delta = GetCurrectAngle(rTurnSectionAngle - agvGoAngle);

            double endAngle = GetCurrectAngle(rTurnSectionAngle + delta);

            if (!dirFlag)
            {
                endAngle = GetCurrectAngle(endAngle - 180);
            }

            newAGVMovingAngle = GetCurrectAngle(end.AGVPosition.Angle + (dirFlag ? 0 : 180));

            if (Math.Abs(GetCurrectAngle(endAngle - end.AGVPosition.Angle)) > turn.SectionAngleChangeMax)
            {
                errorMessage = String.Concat("turnType : ", turn.TurnName,
                                             ", start (", GetMapAGVPositionString(start.AGVPosition), ") VehicleHeadAngle = ", start.AGVPosition.Angle.ToString("0"),
                                             ", end ", GetMapAGVPositionString(end.AGVPosition), " VehicleHeadAngle = ", end.AGVPosition.Angle.ToString("0"),
                                             " 判定角度變化與Config不符合");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        public static string MapAddressToAdressString(MapAddress mapAddress)
        {
            //string s = String.Format("{0}, {1}, {2}, {3}", mp.Address.Street, mp.Address.District, mp.Address.Town, mp.Address.Country);
            MapAddress address = mapAddress;
            string     result  = "";

            if (!address.Street.Equals(""))
            {
                result += " " + address.Street + ",";
            }
            if (!address.District.Equals(""))
            {
                result += " " + address.District + ",";
            }
            if (!address.Town.Equals(""))
            {
                result += " " + address.Town + ",";
            }
            if (!address.Continent.Equals(""))
            {
                result += " " + address.Continent;
            }
            if (result[result.Length - 1].Equals(','))
            {
                result = result.Substring(0, result.Length - 1);
            }
            return(result);
        }
Ejemplo n.º 4
0
        private void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            if (e.Error == null)
            {
                if (e.Result.Count > 0)
                {
                    MapAddress address = e.Result[0].Information.Address;
                    if (address.District == "")
                    {
                        ubicacion.Text   = "" + address.Street + " #" + address.HouseNumber + ", \n" + address.City + ", " + address.City;
                        auxMensajeCalle  = address.Street;
                        auxMensajeAltura = address.HouseNumber;
                        auxMensajeComuna = address.City;
                    }
                    else
                    {
                        ubicacion.Text   = "" + address.Street + " #" + address.HouseNumber + ", \n" + address.District + ", " + address.City;
                        auxMensajeCalle  = address.Street;
                        auxMensajeAltura = address.HouseNumber;
                        auxMensajeComuna = address.District;
                        //auxMensajeCiudad = address.City;
                    }


                    #region

                    /*"Street: "+ address.Street +
                     * "\n House Number: "+address.HouseNumber +
                     * "\n District: " +address.District +
                     * "\n BuildingFloor:  " + address.BuildingFloor +
                     * "\n BuildingName: " + address.BuildingName +
                     * "\n BuildingRoom: " + address.BuildingRoom +
                     * "\n BuildingZone: " + address.BuildingZone +
                     * "\n City: " + address.City +
                     * "\n Continent: " + address.Continent +
                     * "\n Country: " + address.Country +
                     * "\n CountryCode: " + address.CountryCode +
                     * "\n County: " + address.County +
                     * "\n District: " + address.District +
                     * "\n houseNumber: " + address.HouseNumber +
                     * "\n Neighborhood: " + address.Neighborhood +
                     * "\n PostalCode: " + address.PostalCode +
                     * "\n Province: " + address.Province +
                     * "\n State: " + address.State +
                     * "\n StateCode: " + address.StateCode +
                     * "\n Street: " + address.Street +
                     * "\n TownShip: " + address.Township;
                     * "\n  " +address. +*/
                    #endregion
                    //if (address.District==null)
                    //{
                    //    auxMensajeComuna = address.City;
                    //    return;
                    //}

                    //crearDoc();
                }
            }
        }
Ejemplo n.º 5
0
 public AddressPicture(MapAddress address, int pictureWidth, int width, float x, float y)
 {
     this.AddressID = address.Id;
     InitializeComponent();
     InitailPictrue(pictureWidth, width, address);
     this.Location = new Point((int)(x - pictureWidth / 2), (int)(y - pictureWidth / 2));
     //PB_Address.Location = this.Location;
 }
Ejemplo n.º 6
0
        private async void ShowLatestSample(float lat, float lon)
        {
            BeginLoadingIcon();

            mcMap.MapElements.Remove(mLastPatientLocIcon);
            mLastPatientLocIcon.Visible  = true;
            mLastPatientLocIcon.Title    = "Patient is here :)";
            mLastPatientLocIcon.Location = new Geopoint(new BasicGeoposition()
            {
                Latitude = lat, Longitude = lon
            });
            mcMap.MapElements.Add(mLastPatientLocIcon);

            CenterMap(lat, lon, 16);

            MapAddress mapAddr = await Coordinates.CoordsToAddress(lat, lon);

            tbAddress.Text = "(" + lat + ", " + lon + ")";

            if (mapAddr.Street != "")
            {
                if (mapAddr.StreetNumber != "")
                {
                    tbAddress.Text = mapAddr.StreetNumber + " " + mapAddr.Street;
                }
                else
                {
                    tbAddress.Text = mapAddr.Street;
                }
            }


            if (mapAddr.Town != "")
            {
                if (mapAddr.Street != "")
                {
                    tbAddress.Text += ", " + mapAddr.Town;
                }
                else
                {
                    tbAddress.Text = mapAddr.Town;
                }
            }

            if (mapAddr.Country != "")
            {
                if (mapAddr.Town != "")
                {
                    tbAddress.Text += ", " + mapAddr.Country;
                }
                else
                {
                    tbAddress.Text = mapAddr.Country;
                }
            }

            EndLoadingIcon();
        }
Ejemplo n.º 7
0
 public UcAddressImage(MapInfo theMapInfo, MapAddress address)
 {
     InitializeComponent();
     this.theMapInfo = theMapInfo;
     Address         = address;
     Id = Address.Id;
     DrawAddressImage(redPen);
     SetupShowAddressInfo();
 }
        public static string getCompleteAddress(MapAddress mapLocation)
        {
            string houseNumber = mapLocation.HouseNumber;
            string street      = mapLocation.Street;
            string Address     = "";
            string region      = getRegion(mapLocation);
            string city        = mapLocation.City;
            string country     = mapLocation.Country;

            if (string.IsNullOrEmpty(region) && string.IsNullOrEmpty(city) && string.IsNullOrEmpty(country))
            {
                Address = "";
            }
            else if (string.IsNullOrEmpty(region) && string.IsNullOrEmpty(city))
            {
                Address = country;
            }
            else if (string.IsNullOrEmpty(region) && string.IsNullOrEmpty(country))
            {
                Address = city;
            }
            else if (string.IsNullOrEmpty(city) && string.IsNullOrEmpty(country))
            {
                Address = region;
            }
            else if (string.IsNullOrEmpty(region))
            {
                Address = string.Format("{0}, {1} ", city, country);
            }
            else if (string.IsNullOrEmpty(city))
            {
                Address = string.Format("{0}, {1} ", region, country);
            }
            else if (string.IsNullOrEmpty(country))
            {
                Address = string.Format("{0}, {1} ", city, region);
            }
            else if (string.IsNullOrEmpty(houseNumber) && string.IsNullOrEmpty(street))
            {
                Address = string.Format("{0}, {1}, {2} ", city, region, country);
            }
            else if (string.IsNullOrEmpty(houseNumber))
            {
                Address = string.Format("{0}, {1}, {2}, {3}", street, city, region, country);
            }
            else if (string.IsNullOrEmpty(street))
            {
                Address = string.Format("{0}, {1}, {2}, {3}", houseNumber, city, region, country);
            }
            else
            {
                Address = string.Format("{0}, {1}, {2}, {3}, {4}", houseNumber, street, city, region, country);
            }

            return(Address);
        }
        private static string getRegion(MapAddress mapLocation)
        {
            string region = "";

            region = string.IsNullOrEmpty(region) ? mapLocation.Province : region;
            // region = string.IsNullOrEmpty(region) ? mapLocation.County : region;
            region = string.IsNullOrEmpty(region) ? mapLocation.State : region;
            region = string.IsNullOrEmpty(region) ? mapLocation.District : region;
            return(region);
        }
Ejemplo n.º 10
0
 //averigua la direccion postal
 private void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
 {
     if (e.Error == null)
     {
         if (e.Result.Count > 0)
         {
             MapAddress address = e.Result[0].Information.Address;
             Textodireccion.Text = "Estas en " + address.Street + " " + address.HouseNumber + " " + address.City;
         }
     }
 }
Ejemplo n.º 11
0
 void reverseGeocode_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
 {
     if (e.Error == null)
     {
         if (e.Result.Count > 0)
         {
             MapAddress geoAddress = e.Result[0].Information.Address;
             String     city       = geoAddress.City;
             getLocationData(city);
         }
     }
 }
        private string FormatAddress(MapAddress address)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(address.Street).Append(",")
                .Append(address.HouseNumber).Append("\n")
                .Append(address.City).Append("\n")
                .Append(address.Country).Append("\n")
                .Append(address.Continent);

            return sb.ToString();
        }
Ejemplo n.º 13
0
        private string FormatAddress(MapAddress address)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(address.Street).Append(",")
            .Append(address.HouseNumber).Append("\n")
            .Append(address.City).Append("\n")
            .Append(address.Country).Append("\n")
            .Append(address.Continent);

            return(sb.ToString());
        }
Ejemplo n.º 14
0
        public MapAddress FindMapAddressByMapAGVPosition(MapAGVPosition now, string nowSection)
        {
            MapSection  section  = localData.TheMapInfo.AllSection[nowSection];
            MapPosition position = GetTransferPosition(now, section);

            MapAddress returnAddress = new MapAddress();

            returnAddress.InsideSection        = section;
            returnAddress.AGVPosition.Angle    = section.FromVehicleAngle;
            returnAddress.AGVPosition.Position = GetTransferPosition(now, section);

            return(returnAddress);
        }
Ejemplo n.º 15
0
 private void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
 {
     if (e.Error == null)
     {
         if (e.Result.Count > 0)
         {
             MapAddress address = e.Result[0].Information.Address;
             direccion            = "Estas en " + address.Street + " " + address.HouseNumber;
             listacercanos.Header = "Estas en " + address.Street + " " + address.HouseNumber;
         }
     }
     listacercanos.Header = checklocal();
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Translates current location into a two letter ISO country code used
 /// by Nokia Music API. Makes the inital requests to Nokia Music API.
 /// </summary>
 /// <param name="sender">ReverseGeocodeQuery</param>
 /// <param name="e">Event arguments</param>
 private void ReverseGeocodeQuery_QueryCompleted(
     object sender,
     QueryCompletedEventArgs <IList <MapLocation> > e)
 {
     if (e.Error == null)
     {
         if (e.Result.Count > 0)
         {
             MapAddress address = e.Result[0].Information.Address;
             string     twoLetterCountryCode =
                 CountryCodes.TwoLetterFromThreeLetter(address.CountryCode);
             InitializeNokiaMusicApi(twoLetterCountryCode);
         }
     }
 }
Ejemplo n.º 17
0
        private void DrawAddressID(MapAddress address)
        {
            float y = drawMapData.TransferY(address.AGVPosition.Position.Y) + localData.MapConfig.AddressWidth / 2 + 1;

            int size = 8;

            Font font = new Font("微軟正黑體", size);

            SizeF s = drawMapData.Graphics_ObjectAndSection.MeasureString(address.Id, font);

            float x = drawMapData.TransferX(address.AGVPosition.Position.X) - s.Width / 2;

            drawMapData.Graphics_ObjectAndSection.FillRectangle(new SolidBrush(Color.White), x, y, s.Width, s.Height);

            drawMapData.Graphics_ObjectAndSection.DrawString(address.Id, font, Brushes.Black, new PointF(x, y));
        }
Ejemplo n.º 18
0
        private void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <System.Collections.Generic.IList <MapLocation> > e)
        {
            if (e.Error == null)
            {
                if (e.Result.Count > 0)
                {
                    MapAddress address = e.Result[0].Information.Address;

                    //addcity = address.City;
                    //addstate = address.State;
                    //addcountry = address.Country;
                    //addpost = address.PostalCode;
                    addstreet = address.Street;
                }
            }
        }
Ejemplo n.º 19
0
        public SearchAddressViewModel()
        {
            stopService = (App.Current as App).Container.GetService <IStopService>();

            // New up our observable collection
            AddressesFound = new ObservableCollection <StringWrapper>();

            SearchCommand = new RelayCommand(async() =>
            {
                // If our button is showing "search", let's do the following
                if (SearchAddButtonText == "Search")
                {
                    // Reset everything
                    AddressesFound.Clear();
                    AddressSelected = new StringWrapper();

                    MapLocationFinderResult result = await
                                                     MapLocationFinder.FindLocationsAsync(BuildingNumber + " " + StreetName + ", " + PostCode, null);

                    if (result.Status == MapLocationFinderStatus.Success)
                    {
                        MapAddress address = result.Locations.FirstOrDefault().Address;
                        Geopoint point     = result.Locations.FirstOrDefault().Point;
                        var stringw        = new StringWrapper
                        {
                            StringContent = address.FormattedAddress,
                            TempLatitude  = Convert.ToDecimal(point.Position.Latitude),
                            TempLongitude = Convert.ToDecimal(point.Position.Longitude)
                        };
                        AddressesFound.Add(stringw);
                    }
                    else
                    {
                        return;
                    }
                }
                else // it's basically showing "Add" at this point, so add our item to the list of stops
                {
                    StopModel stopModel = new StopModel()
                    {
                        Name     = StopName, Address = AddressSelected.StringContent,
                        Latitude = AddressSelected.TempLatitude, Longitude = AddressSelected.TempLongitude
                    };
                    stopService.AddStop(stopModel);
                }
            });
        }
Ejemplo n.º 20
0
        private void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            if (e.Error == null)
            {
                if (e.Result.Count > 0)
                {
                    MapAddress address    = e.Result[0].Information.Address;
                    String     msgBoxText = "";

                    if (address.Country.Length > 0)
                    {
                        msgBoxText += "\n" + address.Country;
                    }
                    MessageBox.Show(msgBoxText, "Map Explorer", MessageBoxButton.OK);
                }
            }
        }
Ejemplo n.º 21
0
        private async Task <string> reverseGeocodeAsync(Geopoint pointToReverseGeocode)
        {
            // Reverse geocode the specified geographic location.
            MapLocationFinderResult result =
                await MapLocationFinder.FindLocationsAtAsync(pointToReverseGeocode);

            // If the query returns results, display the name of the town
            // contained in the address of the first result.
            if (result.Status == MapLocationFinderStatus.Success)
            {
                MapAddress address = result.Locations.First().Address;
                return(address.FormattedAddress);
            }
            else
            {
                return(null);
            }
        }
        private void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            if (e.Error == null)
            {
                if (e.Result.Count > 0)
                {
                    MapAddress address = e.Result[0].Information.Address;



                    string Header = "";
                    Header = friend + " says";

                    //if (address.Country.Length > 0) msgBoxText += "line\nline\nline\nline\nline\nline\n";
                    MessageBox.Show(msgBoxText, Header, MessageBoxButton.OK);
                }
            }
        }
Ejemplo n.º 23
0
        private void Query_QueryCompleted1(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            try
            {
                string text = "";
                if (e.Cancelled)
                {
                }
                else if (e.Result != null)
                {
                    MapAddress mapaddress     = e.Result[0].Information.Address;
                    string     addressString1 = mapaddress.HouseNumber + " " + mapaddress.Street;
                    string     addressString2 = mapaddress.District + ", " + mapaddress.City;
                    string     addressString3 = mapaddress.Country;
                    if (addressString1 != " ")
                    {
                        addressString1 = addressString1 + "\n";
                    }
                    else
                    {
                        addressString1 = "";
                    }

                    if (addressString2 != ",  ")
                    {
                        addressString2 = addressString2 + "\n";
                    }
                    else
                    {
                        addressString2 = "";
                    }

                    text = addressString1 + addressString2 + addressString3;
                }

                var service = new ServiceReference1.ShipwayServiceSoapClient();
                service.UpdateStatusOfExhibitionAsync(exhibitionId.Text, "Giao thành công", text);
                service.UpdateStatusOfExhibitionCompleted += Service_UpdateStatusOfExhibitionCompleted;
            }
            catch
            {
            }
        }
Ejemplo n.º 24
0
        private void InitailPictrue(int pictureWidth, int width, MapAddress address)
        {
            PB_Address = new PictureBox();
            this.Controls.Add(PB_Address);

            this.BackColor = Color.White;
            int deltaMin = width / 2;
            int deltaMax = (width + 1) / 2;

            this.Size       = new Size(pictureWidth, pictureWidth);
            PB_Address.Size = new Size(pictureWidth, pictureWidth);

            Bitmap   bitmap   = new Bitmap(pictureWidth, pictureWidth);
            Graphics graphics = Graphics.FromImage(bitmap);

            graphics.Clear(Color.White);

            if (address.CanSpin)
            {
                RectangleF rectangleF = new RectangleF(0, 0, pictureWidth - deltaMax, pictureWidth - deltaMax);
                graphics.DrawEllipse(new Pen(Color.DarkBlue, width), rectangleF);
                //graphics.FillPath(new Brush(Color.Red), rectangleF);
            }
            else
            {
                PointF[] xPt = new PointF[4]
                {
                    new PointF(deltaMin, deltaMin),
                    new PointF(deltaMin, pictureWidth - deltaMax),
                    new PointF(pictureWidth - deltaMax, pictureWidth - deltaMax),
                    new PointF(pictureWidth - deltaMax, deltaMin)
                };

                graphics.DrawPolygon(new Pen(Color.Red, width), xPt);
            }

            Bitmap_Address = bitmap;
            bitmap.MakeTransparent(Color.White);
            PB_Address.Image = bitmap;
        }
        static string AddressToString(MapAddress address)
        {
            string building = "", house = "", city = "", country = "";

            var bldg = new List<string>();
            if (!"".Equals(address.BuildingRoom))
                bldg.Add(address.BuildingRoom);
            if (!"".Equals(address.BuildingFloor))
                bldg.Add(address.BuildingFloor);
            if (!"".Equals(address.BuildingName))
                bldg.Add(address.BuildingName);
            if (!"".Equals(address.BuildingWing))
                bldg.Add(address.BuildingWing);
            if (bldg.Count > 0)
                building = string.Join(" ", bldg) + Environment.NewLine;

            var hs = new List<string>();
            if (!"".Equals(address.StreetNumber))
                hs.Add(address.StreetNumber);
            if (!"".Equals(address.Street))
                hs.Add(address.Street);
            if (hs.Count > 0)
                house = string.Join(" ", hs) + Environment.NewLine;

            var cs = new List<string>();
            if (!"".Equals(address.Town))
                cs.Add(address.Town);
            if (!"".Equals(address.Neighborhood))
                cs.Add(address.Neighborhood);
            else if (!"".Equals(address.Region))
                cs.Add(address.Region);
            if (!"".Equals(address.PostCode))
                cs.Add(address.PostCode);
            if (cs.Count > 0)
                city = string.Join(" ", cs) + Environment.NewLine;

            if (!"".Equals(address.Country))
                country = address.Country;
            return building + house + city + country;
        }
        private string FormatAddress(MapAddress address)
        {
            StringBuilder sb = new StringBuilder();

            if (!string.IsNullOrEmpty(address.BuildingName))
            {
                sb.Append(address.HouseNumber).Append(",");
            }
            if (!string.IsNullOrEmpty(address.Street))
            {
                sb.Append(address.Street).Append(",");
            }
            if (!string.IsNullOrEmpty(address.City))
            {
                sb.Append(address.City).Append(",");
            }
            if (!string.IsNullOrEmpty(address.Country))
            {
                sb.Append(address.Country);
            }
            return(sb.ToString());
        }
        private void btnSearchMapAddress_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtMapAddress.Text.Trim()))
                {
                    return;
                }

                string addressId = txtMapAddress.Text.Trim();

                if (MapInfo.addressMap.ContainsKey(addressId))
                {
                    MapAddress mapAddress = Vehicle.Mapinfo.addressMap[addressId];
                    MapAddressFitMoveCommand(mapAddress);
                }
            }
            catch (Exception ex)
            {
                LogException(GetType().Name + ":" + MethodBase.GetCurrentMethod().Name, ex.Message);
            }
        }
        private static string AddressToString(MapAddress address)
        {
            string str1 = "";
            string str2 = "";
            string str3 = "";
            string str4 = "";
            string str5 = "";
            string str6 = "";
            List<string> list1 = new List<string>();
            if (!string.IsNullOrEmpty(address.BuildingRoom))
                list1.Add(address.BuildingRoom);
            if (!string.IsNullOrEmpty(address.BuildingFloor))
                list1.Add(address.BuildingFloor);
            if (!string.IsNullOrEmpty(address.BuildingName))
                list1.Add(address.BuildingName);
            if (!string.IsNullOrEmpty(address.BuildingWing))
                list1.Add(address.BuildingWing);
            if (list1.Count > 0)
                str1 = string.Join(" ", (IEnumerable<string>)list1) + ", ";

            List<string> list2 = new List<string>();
            if (!string.IsNullOrEmpty(address.StreetNumber))
                list2.Add(address.StreetNumber);
            if (!string.IsNullOrEmpty(address.Street))
                list2.Add(address.Street);
            if (list2.Count > 0)
                str2 = string.Join(" ", (IEnumerable<string>)list2) + ", ";

            if (!string.IsNullOrEmpty(address.Town))
                str3 = address.Town + ", ";
            if (!string.IsNullOrEmpty(address.Region))
                str4 = address.Region + ", ";
            if (!string.IsNullOrEmpty(address.PostCode))
                str5 = address.PostCode + ", ";
            if (!string.IsNullOrEmpty(address.Country))
                str6 = address.Country;
            return str1 + str2 + str3 + str4 + str5 + str6;
        }
        private string FormatAddress(MapAddress address)
        {
            StringBuilder b = new StringBuilder();

            if (!string.IsNullOrWhiteSpace(address.HouseNumber))
            {
                b.AppendFormat("{0} ", address.HouseNumber);
            }

            if (!string.IsNullOrWhiteSpace(address.Street))
            {
                b.AppendFormat("{0}\n", address.Street);
            }

            if (!string.IsNullOrWhiteSpace(address.City))
            {
                b.AppendFormat("{0}, ", address.City);
            }

            b.AppendFormat("{0}  {1}", address.State, address.PostalCode);

            return(b.ToString());
        }
Ejemplo n.º 30
0
 /// <summary>
 /// Event handler for reverse geocode query.
 /// </summary>
 /// <param name="e">Results of the reverse geocode query - list of locations</param>
 private void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
 {
     if (e.Error == null)
     {
         if (e.Result.Count > 0)
         {
             MapAddress address    = e.Result[0].Information.Address;
             String     msgBoxText = "";
             if (address.Street.Length > 0)
             {
                 msgBoxText += "\n" + address.Street;
                 if (address.HouseNumber.Length > 0)
                 {
                     msgBoxText += " " + address.HouseNumber;
                 }
             }
             if (address.PostalCode.Length > 0)
             {
                 msgBoxText += "\n" + address.PostalCode;
             }
             if (address.City.Length > 0)
             {
                 msgBoxText += "\n" + address.City;
             }
             if (address.Country.Length > 0)
             {
                 msgBoxText += "\n" + address.Country;
             }
             MessageBox.Show(msgBoxText, AppResources.ApplicationTitle, MessageBoxButton.OK);
         }
         else
         {
             MessageBox.Show(AppResources.NoInfoMessageBoxText, AppResources.ApplicationTitle, MessageBoxButton.OK);
         }
         MyReverseGeocodeQuery.Dispose();
     }
 }
 private string GetAddress(MapAddress address)
 {
     string result = "";
     if (address.HouseNumber != "")
         result += address.HouseNumber + ", ";
     if (address.Street != "")
         result += address.Street + ", ";
     if (address.County != "")
         result += address.County + ", ";
     if (address.District != "")
         result += address.District + ", ";
     if (address.City != "")
         result += address.City + ", ";
     if (address.Country != "")
         result += address.Country;
     return result;
 }
 private static string getRegion(MapAddress mapLocation)
 {
     string region = "";
     region = string.IsNullOrEmpty(region) ? mapLocation.Province : region;
     // region = string.IsNullOrEmpty(region) ? mapLocation.County : region;
     region = string.IsNullOrEmpty(region) ? mapLocation.State : region;
     region = string.IsNullOrEmpty(region) ? mapLocation.District : region;
     return region;
 }
Ejemplo n.º 33
0
        public void ReadAddressCsv()
        {
            try
            {
                if (string.IsNullOrWhiteSpace(AddressPath))
                {
                    mirleLogger.Log(new LogFormat("Error", "5", GetType().Name + ":" + MethodBase.GetCurrentMethod().Name, "Device", "CarrierID"
                                                  , $"IsAddressPathNull={string.IsNullOrWhiteSpace(AddressPath)}"));
                    return;
                }
                Vehicle.MapInfo.addressMap.Clear();
                Vehicle.MapInfo.chargerAddressMap.Clear();

                string[] allRows = File.ReadAllLines(AddressPath);
                if (allRows == null || allRows.Length < 2)
                {
                    mirleLogger.Log(new LogFormat("Error", "5", GetType().Name + ":" + MethodBase.GetCurrentMethod().Name, "Device", "CarrierID"
                                                  , $"There are no address in file"));
                    return;
                }

                string[] titleRow = allRows[0].Split(',');
                allRows = allRows.Skip(1).ToArray();

                int nRows    = allRows.Length;
                int nColumns = titleRow.Length;

                Dictionary <string, int> dicHeaderIndexes = new Dictionary <string, int>();
                for (int i = 0; i < nColumns; i++)
                {
                    var keyword = titleRow[i].Trim();
                    if (!string.IsNullOrWhiteSpace(keyword))
                    {
                        dicHeaderIndexes.Add(keyword, i);
                    }
                }

                for (int i = 0; i < nRows; i++)
                {
                    string[]         getThisRow = allRows[i].Split(',');
                    MapAddress       oneRow     = new MapAddress();
                    MapAddressOffset offset     = new MapAddressOffset();
                    try
                    {
                        oneRow.Id         = getThisRow[dicHeaderIndexes["Id"]];
                        oneRow.Position.X = double.Parse(getThisRow[dicHeaderIndexes["PositionX"]]);
                        oneRow.Position.Y = double.Parse(getThisRow[dicHeaderIndexes["PositionY"]]);
                        if (dicHeaderIndexes.ContainsKey("TransferPortDirection"))
                        {
                            oneRow.TransferPortDirection = oneRow.AddressDirectionParse(getThisRow[dicHeaderIndexes["TransferPortDirection"]]);
                        }
                        if (dicHeaderIndexes.ContainsKey("GateType"))
                        {
                            oneRow.GateType = getThisRow[dicHeaderIndexes["GateType"]];
                        }
                        if (dicHeaderIndexes.ContainsKey("ChargeDirection"))
                        {
                            oneRow.ChargeDirection = oneRow.AddressDirectionParse(getThisRow[dicHeaderIndexes["ChargeDirection"]]);
                        }
                        if (dicHeaderIndexes.ContainsKey("PioDirection"))
                        {
                            oneRow.PioDirection = oneRow.AddressDirectionParse(getThisRow[dicHeaderIndexes["PioDirection"]]);
                        }
                        //oneRow.CanSpin = bool.Parse(getThisRow[dicHeaderIndexes["CanSpin"]]);
                        //oneRow.IsTR50 = bool.Parse(getThisRow[dicHeaderIndexes["IsTR50"]]);
                        if (dicHeaderIndexes.ContainsKey("InsideSectionId"))
                        {
                            oneRow.InsideSectionId = FitZero(getThisRow[dicHeaderIndexes["InsideSectionId"]]);
                        }
                        if (dicHeaderIndexes.ContainsKey("OffsetX"))
                        {
                            offset.OffsetX     = double.Parse(getThisRow[dicHeaderIndexes["OffsetX"]]);
                            offset.OffsetY     = double.Parse(getThisRow[dicHeaderIndexes["OffsetY"]]);
                            offset.OffsetTheta = double.Parse(getThisRow[dicHeaderIndexes["OffsetTheta"]]);
                        }
                        oneRow.AddressOffset = offset;
                        if (dicHeaderIndexes.ContainsKey("VehicleHeadAngle"))
                        {
                            oneRow.VehicleHeadAngle = double.Parse(getThisRow[dicHeaderIndexes["VehicleHeadAngle"]]);
                        }
                    }
                    catch (Exception ex)
                    {
                        mirleLogger.Log(new LogFormat("Error", "5", GetType().Name + ":" + MethodBase.GetCurrentMethod().Name, "Device", "CarrierID", $"LoadAddressCsv read oneRow : [lastReadAdrId={lastReadAdrId}]"));
                        LogException(GetType().Name + ":" + MethodBase.GetCurrentMethod().Name, ex.Message);
                    }

                    lastReadAdrId = oneRow.Id;
                    Vehicle.MapInfo.addressMap.TryAdd(oneRow.Id, oneRow);
                    if (oneRow.IsCharger())
                    {
                        Vehicle.MapInfo.chargerAddressMap.Add(oneRow);
                    }
                    Vehicle.MapInfo.gateTypeMap.Add(oneRow.Id, oneRow.GateType);
                }

                LogDebug(GetType().Name + ":" + MethodBase.GetCurrentMethod().Name, $"Load Address File Ok. [lastReadAdrId={lastReadAdrId}]");
            }
            catch (Exception ex)
            {
                LogException(GetType().Name + ":" + MethodBase.GetCurrentMethod().Name, $"LoadAddressCsv : [lastReadAdrId={lastReadAdrId}]");
                LogException(GetType().Name + ":" + MethodBase.GetCurrentMethod().Name, ex.Message);
            }
        }
        public static string getCompleteAddress(MapAddress mapLocation)
        {
            string houseNumber = mapLocation.HouseNumber;
            string street = mapLocation.Street;
            string Address = "";
            string region = getRegion(mapLocation);
            string city = mapLocation.City;
            string country = mapLocation.Country;

            if (string.IsNullOrEmpty(region) && string.IsNullOrEmpty(city) && string.IsNullOrEmpty(country))
                Address = "";
            else if (string.IsNullOrEmpty(region) && string.IsNullOrEmpty(city))
                Address = country;
            else if (string.IsNullOrEmpty(region) && string.IsNullOrEmpty(country))
                Address = city;
            else if (string.IsNullOrEmpty(city) && string.IsNullOrEmpty(country))
                Address = region;
            else if (string.IsNullOrEmpty(region))
                Address = string.Format("{0}, {1} ", city, country);
            else if (string.IsNullOrEmpty(city))
                Address = string.Format("{0}, {1} ", region, country);
            else if (string.IsNullOrEmpty(country))
                Address = string.Format("{0}, {1} ", city, region);
            else if (string.IsNullOrEmpty(houseNumber) && string.IsNullOrEmpty(street))
                Address = string.Format("{0}, {1}, {2} ", city, region, country);
            else if (string.IsNullOrEmpty(houseNumber))
                Address = string.Format("{0}, {1}, {2}, {3}", street, city, region, country);
            else if (string.IsNullOrEmpty(street))
                Address = string.Format("{0}, {1}, {2}, {3}", houseNumber, city, region, country);
            else
                Address = string.Format("{0}, {1}, {2}, {3}, {4}", houseNumber, street, city, region, country);

            return Address;
        }
        private static string AddressToString(MapAddress address)
        {
            string str1 = String.Empty, str2 = String.Empty, str3 = String.Empty, str4 = String.Empty;

            List <string> line1 = new List <string>();

            if (address.BuildingRoom.IsNotNullOrEmpty())
            {
                line1.Add(address.BuildingRoom);
            }
            if (address.BuildingFloor.IsNotNullOrEmpty())
            {
                line1.Add(address.BuildingFloor);
            }
            if (address.BuildingName.IsNotNullOrEmpty())
            {
                line1.Add(address.BuildingName);
            }
            if (line1.Count > 0)
            {
                str1 = string.Join(" ", line1) + Environment.NewLine;
            }

            List <string> line2 = new List <string>();

            if (address.StreetNumber.IsNotNullOrEmpty())
            {
                line2.Add(address.StreetNumber);
            }
            if (address.Street.IsNotNullOrEmpty())
            {
                line2.Add(address.Street);
            }
            if (line2.Count > 0)
            {
                str2 = string.Join(" ", line2) + Environment.NewLine;
            }

            List <string> line3 = new List <string>();

            if (address.Town.IsNotNullOrEmpty())
            {
                line3.Add(address.Town);
            }
            if (address.Region.IsNotNullOrEmpty())
            {
                line3.Add(address.Region);
            }
            if (address.PostCode.IsNotNullOrEmpty())
            {
                line3.Add(address.PostCode);
            }
            if (line3.Count > 0)
            {
                str3 = string.Join(" ", line3) + Environment.NewLine;
            }

            if (!string.IsNullOrEmpty(address.Country))
            {
                str4 = address.Country;
            }

            return($"{str1}{str2}{str3}{str4}");
        }
Ejemplo n.º 36
0
        static string AddressToString(MapAddress address)
        {
            string building = "", house = "", city = "", country = "";

            var bldg = new List <string>();

            if (!"".Equals(address.BuildingRoom))
            {
                bldg.Add(address.BuildingRoom);
            }
            if (!"".Equals(address.BuildingFloor))
            {
                bldg.Add(address.BuildingFloor);
            }
            if (!"".Equals(address.BuildingName))
            {
                bldg.Add(address.BuildingName);
            }
            if (!"".Equals(address.BuildingWing))
            {
                bldg.Add(address.BuildingWing);
            }
            if (bldg.Count > 0)
            {
                building = string.Join(" ", bldg) + Environment.NewLine;
            }

            var hs = new List <string>();

            if (!"".Equals(address.StreetNumber))
            {
                hs.Add(address.StreetNumber);
            }
            if (!"".Equals(address.Street))
            {
                hs.Add(address.Street);
            }
            if (hs.Count > 0)
            {
                house = string.Join(" ", hs) + Environment.NewLine;
            }

            var cs = new List <string>();

            if (!"".Equals(address.Town))
            {
                cs.Add(address.Town);
            }
            if (!"".Equals(address.Neighborhood))
            {
                cs.Add(address.Neighborhood);
            }
            else if (!"".Equals(address.Region))
            {
                cs.Add(address.Region);
            }
            if (!"".Equals(address.PostCode))
            {
                cs.Add(address.PostCode);
            }
            if (cs.Count > 0)
            {
                city = string.Join(" ", cs) + Environment.NewLine;
            }

            if (!"".Equals(address.Country))
            {
                country = address.Country;
            }
            return(building + house + city + country);
        }
      private string FormatAddress(MapAddress address)
      {
         StringBuilder b = new StringBuilder();

         if (!string.IsNullOrWhiteSpace(address.HouseNumber))
            b.AppendFormat("{0} ", address.HouseNumber);

         if (!string.IsNullOrWhiteSpace(address.Street))
            b.AppendFormat("{0}\n", address.Street);

         if (!string.IsNullOrWhiteSpace(address.City))
            b.AppendFormat("{0}, ", address.City);

         b.AppendFormat("{0}  {1}", address.State, address.PostalCode);

         return b.ToString();
      }
Ejemplo n.º 38
0
 private string createAddressString(MapAddress address)
 //helper to create address string
 {
     string addressString = "";
     if (address.HouseNumber != "")
     {
         addressString = address.HouseNumber + " ";
     }
     if (address.Street != "")
     {
         addressString += address.Street;
         addressString += ", ";
     }
     if (address.District != "")
     {
         addressString += address.District;
     }
     return addressString;
 }