示例#1
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            Dictionary <string, object> d = new Dictionary <string, object> (StringComparer.Ordinal);

            LocationCoordinate coordinate = new LocationCoordinate();

            if (obj.GetType() == Type.GetType("Unity.Core.Geo.LocationCoordinate"))
            {
                coordinate = (LocationCoordinate)obj;
            }

            d.Add("XCoordinate", coordinate.XCoordinate);
            d.Add("YCoordinate", coordinate.YCoordinate);
            d.Add("ZCoordinate", coordinate.ZCoordinate);
            d.Add("XDoP", coordinate.XDoP);
            d.Add("YDoP", coordinate.YDoP);

            return(d);
        }
示例#2
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            object objX = dictionary ["XCoordinate"];
            string sX   = objX.ToString();

            sX = sX.Replace(',', '.');
            double XCoordinate = Double.Parse(sX, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo());

            object objY = dictionary ["YCoordinate"];
            string sY   = objY.ToString();

            sY = sY.Replace(',', '.');
            double YCoordinate = Double.Parse(sY, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo());

            object objZ = dictionary ["ZCoordinate"];
            string sZ   = objZ.ToString();

            sZ = sZ.Replace(',', '.');
            double ZCoordinate = Double.Parse(sZ, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo());

            object objXDop = dictionary ["XDoP"];
            string sXDop   = objXDop.ToString();

            sXDop = sXDop.Replace(',', '.');
            float XDop = Single.Parse(sXDop, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo());

            object objYDop = dictionary ["YDoP"];
            string sYDop   = objYDop.ToString();

            sYDop = sYDop.Replace(',', '.');
            float YDop = Single.Parse(sYDop, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo());

            LocationCoordinate coordinate = new LocationCoordinate();

            coordinate.XCoordinate = XCoordinate;
            coordinate.YCoordinate = YCoordinate;
            coordinate.ZCoordinate = ZCoordinate;
            coordinate.XDoP        = XDop;
            coordinate.YDoP        = YDop;
            return(coordinate);
        }
示例#3
0
 public override POI[] GetPOIList(LocationCoordinate location, float radius, string queryText)
 {
     LocationCategory dummyLocCat = new LocationCategory();
     dummyLocCat.Name = ".*";
     return GetPOIList(location, radius, queryText, dummyLocCat);
 }
示例#4
0
 public override POI[] GetPOIList(LocationCoordinate location, float radius, string queryText, LocationCategory category)
 {
     List<POI> poisInRadius = getPoisInRadius (location, radius);
     List<POI> poisMatchQuery = getPoisMatchQuery (poisInRadius, queryText);
     List<POI> poisFinal = getPoisMatchCategory (poisMatchQuery, category);
     return poisFinal.ToArray ();
 }
示例#5
0
 public override POI[] GetPOIList(LocationCoordinate location, float radius, LocationCategory category)
 {
     return GetPOIList (location, radius, ".*", category);
 }
 public override async Task<POI[]> GetPOIList(LocationCoordinate location, float radius, string queryText)
 {
     throw new NotImplementedException();
 }
示例#7
0
 public abstract Task<POI[]> GetPOIList(LocationCoordinate location, float radius, string queryText);
示例#8
0
 public abstract POI[] GetPOIList(LocationCoordinate location, float radius);
示例#9
0
 public abstract POI[] GetPOIList(LocationCoordinate location, float radius, LocationCategory category);
示例#10
0
 public abstract POI[] GetPOIList(LocationCoordinate location, float radius, string queryText);
示例#11
0
 public abstract POI[] GetPOIList(LocationCoordinate location, float radius);
示例#12
0
 public abstract Task <POI[]> GetPOIList(LocationCoordinate location, float radius, string queryText, LocationCategory category);
示例#13
0
 public override POI[] GetPOIList(LocationCoordinate location, float radius, string queryText, LocationCategory category)
 {
     throw new NotImplementedException();
 }
示例#14
0
 public override POI[] GetPOIList(LocationCoordinate location, float radius)
 {
     throw new NotImplementedException();
 }
示例#15
0
 public override async Task<POI[]> GetPOIList(LocationCoordinate location, float radius, LocationCategory category)
 {
     throw new NotImplementedException();
 }
示例#16
0
        private POI getPoiFromId(string id)
        {
            POI poi = new POI ();
            LocationCoordinate locCoord = new LocationCoordinate ();
            LocationDescription locDesc = new LocationDescription ();
            LocationCategory locCat = new LocationCategory ();
            List<LocationCategory> listCategories = new List<LocationCategory> ();

            string selectFromPOI = "SELECT * FROM \"POI\" WHERE ID='" + id + "'";
            IResultSet resultSelectPoi = mapDDBB.ExecuteSQLQuery (mapDDBB.GetDatabase (mapDDBBName), selectFromPOI);

            if (resultSelectPoi.GetRowCount () > 0) {
                string selectLocationCoordinateForPoId = "SELECT * FROM \"LOCATIONCOORDINATE\" WHERE POI_ID='" + id + "'";
                string selectLocationDescriptionForPoiId = "SELECT * FROM \"LOCATIONDESCRIPTION\" WHERE POI_ID='" + id + "'";
                string selectSecondaryCategoryForPoiId = "SELECT * FROM \"SECONDARYCATEGORY\" WHERE POI_ID='" + id + "'";

                IResultSet resultSetSelectLocCoord = mapDDBB.ExecuteSQLQuery (mapDDBB.GetDatabase (mapDDBBName), selectLocationCoordinateForPoId);
                IResultSet resultSetSelectLocDescr = mapDDBB.ExecuteSQLQuery (mapDDBB.GetDatabase (mapDDBBName), selectLocationDescriptionForPoiId);
                IResultSet resultSetSelectSecondCat = mapDDBB.ExecuteSQLQuery (mapDDBB.GetDatabase (mapDDBBName), selectSecondaryCategoryForPoiId);

                double latitude = resultSetSelectLocCoord.GetDouble ("LATITUDE");
                double longitude = resultSetSelectLocCoord.GetDouble ("LONGITUDE");
                double altitude = resultSetSelectLocCoord.GetDouble ("ALTITUDE");
                float horAccur = resultSetSelectLocCoord.GetFloat ("HORIZONTALACCURACY");
                float verAccur = resultSetSelectLocCoord.GetFloat ("VERTICALACCURACY");

                string description = resultSetSelectLocDescr.GetString ("DESCRIPTION");
                string name = resultSetSelectLocDescr.GetString ("NAME");
                string catMainName = resultSetSelectLocDescr.GetString ("CATEGORYMAINNAME");

                poi.ID = id;

                locCoord.XCoordinate = latitude;
                locCoord.YCoordinate = longitude;
                locCoord.ZCoordinate = altitude;
                locCoord.XDoP = horAccur;
                locCoord.YDoP = verAccur;

                poi.Location = locCoord;

                locDesc.Description = description;
                locDesc.Name = name;
                locCat.Name = catMainName;
                locDesc.CategoryMain = locCat;

                int numRowsSecCat = resultSetSelectSecondCat.GetRowCount ();
                for (int i = 0; i < numRowsSecCat; i++) {
                    string secondCatName = resultSetSelectSecondCat.GetString ("SECONDCATEGORYNAME");
                    LocationCategory locCategory = new LocationCategory ();
                    locCategory.Name = secondCatName;
                    listCategories.Add (locCategory);
                    resultSetSelectSecondCat.MoveToNext ();

                }

                locDesc.Categories = listCategories.ToArray ();
                poi.Description = locDesc;

                poi.Category = locCat;

            }  else {
                poi = null;
            }

            return poi;
        }
示例#17
0
        private List<POI> getPoisInRadius(LocationCoordinate location, float radius)
        {
            List<POI> pois = new List<POI> ();
            string selectFromLocationCoordinate = "SELECT * FROM \"LOCATIONCOORDINATE\"";
            IResultSet resultSetFromLocationCoordinate = mapDDBB.ExecuteSQLQuery (mapDDBB.GetDatabase (mapDDBBName), selectFromLocationCoordinate);
            int numRows = resultSetFromLocationCoordinate.GetRowCount ();
            for (int i = 0; i < numRows; i++) {
                double latitude = resultSetFromLocationCoordinate.GetDouble ("LATITUDE");
                double longitude = resultSetFromLocationCoordinate.GetDouble ("LONGITUDE");
                string poiId = resultSetFromLocationCoordinate.GetString ("POI_ID");
                double distance = GeoUtils.GetInstance().evaluateDistanceSphericalLawOfCosines (location.XCoordinate, location.YCoordinate, latitude, longitude);
                #if DEBUG
                SystemLogger.Log (SystemLogger.Module.PLATFORM, "getPoisInRadius: lat1:" + location.XCoordinate + " lon1:" + location.YCoordinate + " lat2:" + latitude + " lon2:" + longitude + " Distance:" + distance + " Radius:" + radius);
                #endif
                if (distance <= radius) {
                    POI poi = getPoiFromId (poiId);
                    if (poi != null) {
                        pois.Add (poi);
                        #if DEBUG
                        SystemLogger.Log (SystemLogger.Module.PLATFORM, "getPoisInRadius: Added POI_ID:" + poi.ID + " Latitude:" + latitude + " Longitude:" + longitude + " because:" + distance + "<=" + radius);
                        #endif
                    }
                }
                resultSetFromLocationCoordinate.MoveToNext ();
            }

            return pois;
        }
        public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            Dictionary<string, object> d = new Dictionary<string, object> (StringComparer.Ordinal);

            LocationCoordinate coordinate = new LocationCoordinate ();
            if (obj.GetType () == Type.GetType ("Unity.Core.Geo.LocationCoordinate")) {
                coordinate = (LocationCoordinate)obj;
            }

            d.Add ("XCoordinate", coordinate.XCoordinate);
            d.Add ("YCoordinate", coordinate.YCoordinate);
            d.Add ("ZCoordinate", coordinate.ZCoordinate);
            d.Add ("XDoP", coordinate.XDoP);
            d.Add ("YDoP", coordinate.YDoP);

            return d;
        }
示例#19
0
 public abstract POI[] GetPOIList(LocationCoordinate location, float radius, string queryText, LocationCategory category);
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            object objX = dictionary ["XCoordinate"];
            string sX = objX.ToString ();
            sX = sX.Replace (',', '.');
            double XCoordinate = Double.Parse (sX, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo ());

            object objY = dictionary ["YCoordinate"];
            string sY = objY.ToString ();
            sY = sY.Replace (',', '.');
            double YCoordinate = Double.Parse (sY, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo ());

            object objZ = dictionary ["ZCoordinate"];
            string sZ = objZ.ToString ();
            sZ = sZ.Replace (',', '.');
            double ZCoordinate = Double.Parse (sZ, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo ());

            object objXDop = dictionary ["XDoP"];
            string sXDop = objXDop.ToString ();
            sXDop = sXDop.Replace (',', '.');
            float XDop = Single.Parse (sXDop, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo ());

            object objYDop = dictionary ["YDoP"];
            string sYDop = objYDop.ToString ();
            sYDop = sYDop.Replace (',', '.');
            float YDop = Single.Parse (sYDop, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, FormatUtils.GetNumberFormatInfo ());

            LocationCoordinate coordinate = new LocationCoordinate ();
            coordinate.XCoordinate = XCoordinate;
            coordinate.YCoordinate = YCoordinate;
            coordinate.ZCoordinate = ZCoordinate;
            coordinate.XDoP = XDop;
            coordinate.YDoP = YDop;
            return coordinate;
        }
示例#21
0
 public abstract Task<POI[]> GetPOIList(LocationCoordinate location, float radius, LocationCategory category);
示例#22
0
        public override async Task<LocationCoordinate> GetCoordinates()
        {

            try
            {
                var currentPosition = _lastKnownCoordinate ?? (await _geoLocator.GetGeopositionAsync(new TimeSpan(0, 0, 10), new TimeSpan(0, 0, 6))).Coordinate;
                var returnCoordinate = new LocationCoordinate
                {
                    XCoordinate = currentPosition.Point.Position.Latitude,
                    YCoordinate = currentPosition.Point.Position.Longitude,
                    ZCoordinate = currentPosition.Point.Position.Altitude
                };

                if (_lastKnownCoordinate == null || _lastKnownCoordinate.SatelliteData == null) return returnCoordinate;
                returnCoordinate.XDoP = (float)(_lastKnownCoordinate.SatelliteData.HorizontalDilutionOfPrecision ?? 0);
                returnCoordinate.YDoP = (float)(_lastKnownCoordinate.SatelliteData.VerticalDilutionOfPrecision ?? 0);
                return returnCoordinate;
            }
            catch (Exception ex)
            {
                WindowsPhoneUtils.Log(ex.Message);
            }
            return null;
        }