public static SharpMap.Data.FeatureDataRow FindGeoNearPoint( GeoAPI.Geometries.IPoint point, SharpMap.Layers.VectorLayer layer, double amountGrow) { var box = new GeoAPI.Geometries.Envelope(point.Coordinate); box.ExpandBy(amountGrow); var fds = new SharpMap.Data.FeatureDataSet(); layer.DataSource.ExecuteIntersectionQuery(box, fds); SharpMap.Data.FeatureDataRow result = null; var minDistance = double.MaxValue; foreach (SharpMap.Data.FeatureDataTable fdt in fds.Tables) { foreach (SharpMap.Data.FeatureDataRow fdr in fdt.Rows) { if (fdr.Geometry != null) { var distance = point.Distance(fdr.Geometry); if (distance < minDistance) { result = fdr; minDistance = distance; } } } } return(result); }
public void Buffer() { Random rnd = new Random(); Coordinate coords = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90); double x = coords.X; double y = coords.Y; GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y); //coordscheck[i] = c; Point p = new Point(coords); GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory(); GeoAPI.Geometries.IPoint ps = gf.CreatePoint(c); double area = p.Buffer(500).Area; double areacheck = ps.Buffer(500).Area; Assert.AreEqual(area, areacheck); }
private static SharpMap.Data.FeatureDataTable TransformedFeatureDataTable( System.Drawing.Drawing2D.Matrix matrix, SharpMap.Data.FeatureDataTable fdt) { SharpMap.Data.FeatureDataTable fdtClone = new SharpMap.Data.FeatureDataTable(fdt); fdtClone.Clear(); foreach (SharpMap.Data.FeatureDataRow row in fdt) { SharpMap.Data.FeatureDataRow newRow = fdtClone.NewRow(); for (System.Int32 i = 0; i < fdtClone.Columns.Count; i++) newRow[i] = row[i]; GeoAPI.Geometries.IPoint smpt = (GeoAPI.Geometries.IPoint)row.Geometry; System.Drawing.PointF[] pts = new System.Drawing.PointF[] { new System.Drawing.PointF((float)smpt.X, (float)smpt.Y) }; matrix.TransformPoints(pts); newRow.Geometry = new NetTopologySuite.Geometries.Point(pts[0].X, pts[0].Y); fdtClone.AddRow(newRow); } return fdtClone; }
public static Vec GetVec(this GeoAPI.Geometries.IPoint c) { return(new Vec(c.X, c.Y)); }
public static Point GetWindowsPoint(this GeoAPI.Geometries.IPoint c) { return(new Point(c.X, c.Y)); }
public async Task <HttpResult> Search([FromBody] GymSearch q) { try { int takeAmount = 10; int pageNum = q.Page; string k = q.Keywords.ToLower().Trim(); //if (string.IsNullOrEmpty(k)) // k = " "; ////for some reason search takes less time if given keyword is not empty... List <string> queryWords = k.Replace(',', ' ').Split(' ').Where(x => x.Length > 0).ToList(); IQueryable <GymFinderGym> gyms = (from g in db.GymFinderGym //let citySearch = city.Id > 0 where ( (g.Status == q.Status || q.Status == (int)Enums.GymStatus.Any) && ( string.IsNullOrEmpty(k) || queryWords.Any(w => g.Name.ToLower().Contains(w)) || queryWords.Any(w => g.StreetAddress.ToLower().Contains(w)) || queryWords.Any(w => g.LocationCityName.ToLower().Contains(w)) || queryWords.Any(w => g.LocationCountryName.ToLower().Contains(w)) || queryWords.All(w => g.Description.ToLower().Contains(w)) ) //&& //( // q.CityID == city.Id || !citySearch //) && (q.Cafe == g.Cafe || q.Cafe != 1) && (q.CardioMachines == g.CardioMachines || q.CardioMachines != 1) && (q.ChangingRooms == g.ChangingRooms || q.ChangingRooms != 1) && (q.ClassesAvailable == g.ClassesAvailable || q.ClassesAvailable != 1) && (q.Crossfit == g.Crossfit || q.Crossfit != 1) && (q.FreeWeightsBarsPlates == g.FreeWeightsBarsPlates || q.FreeWeightsBarsPlates != 1) && (q.FreeWeightsDumbbells == g.FreeWeightsDumbbells || q.FreeWeightsDumbbells != 1) && (q.MembersOnly == g.MembersOnly || q.MembersOnly != 1) && (q.NoMembershipRequired == g.NoMembershipRequired || q.NoMembershipRequired != 1) && (q.OlympicLifting == g.OlympicLifting || q.OlympicLifting != 1) && (q.Physio == g.Physio || q.Physio != 1) && (q.Powerlifting == g.Powerlifting || q.Powerlifting != 1) && (q.ResistanceMachines == g.ResistanceMachines || q.ResistanceMachines != 1) && (q.Sauna == g.Sauna || q.Sauna != 1) && (q.SwimmingPool == g.SwimmingPool || q.SwimmingPool != 1) && (q.Toilets == g.Toilets || q.Toilets != 1) && (q.TwentyFourHour == g.TwentyFourHour || q.TwentyFourHour != 1) && (q.VendingMachine == g.VendingMachine || q.VendingMachine != 1) && (q.Strongman == g.Strongman || q.Strongman != 1) && (q.Lockers == g.Lockers || q.Lockers != 1) ) select g); int total = gyms.Count(); CityGeo city = await db.CityGeo.FindAsync(q.CityID); //if (city == null) // city = new CityGeo { Id = 0 }; if (city != null) {//sort by distance first if city selected GeoAPI.Geometries.IGeometryFactory geometryFactory = NtsGeometryServices.Instance.CreateGeometryFactory(srid: 4326); GeoAPI.Geometries.IPoint cityLocation = geometryFactory.CreatePoint(new GeoAPI.Geometries.Coordinate((double)city.Latitude, (double)city.Longitude)); gyms = gyms .OrderBy(x => new GeoAPI.Geometries.Coordinate(x.LocationLat, x.LocationLong).Distance(cityLocation.Coordinate)) .ThenByDescending(x => x.CreationDate); } else if (!string.IsNullOrEmpty(k)) {//else sort by keyword relevance only gyms = gyms .OrderByDescending(x => x.Name.ToLower().StartsWith(k)) .ThenByDescending(x => x.CreationDate); } else {//else sort by rating gyms = gyms.OrderByDescending(x => x.AverageRating); } gyms = gyms.Skip(pageNum * takeAmount).Take(takeAmount); return(new HttpResult(true, new { gyms, total }, "")); } catch (Exception e) { return(new HttpResult(false, null, Functions.ErrorMessage(e))); } }
public GeoAPI.Geometries.IEnvelope Union(GeoAPI.Geometries.IPoint point) { throw new NotImplementedException(); }
public void SetCentre(GeoAPI.Geometries.IPoint centre, double width, double height) { throw new NotImplementedException(); }
public void SetCentre(GeoAPI.Geometries.IPoint centre) { throw new NotImplementedException(); }
public async Task <HttpResult> Search([FromBody] CoachSearch q) { try { int takeAmount = 15; int pageNum = q.Page; string k = q.Keywords.ToLower().Trim(); List <string> queryWords = k.Replace(',', ' ').Split(' ').Where(x => x.Length > 0).ToList(); var coaches = (from u in db.User //let citySearch = city.Id > 0 where ( u.IsCoach == 1 && (u.Status == q.Status || q.Status == (int)Enums.UserStatus.Active) && ( string.IsNullOrEmpty(k) || queryWords.Any(w => u.FirstName.ToLower().Contains(w)) || queryWords.Any(w => u.LastName.ToLower().Contains(w)) || queryWords.Any(w => u.CityName.ToLower().Contains(w)) || queryWords.Any(w => u.CountryName.ToLower().Contains(w)) || queryWords.All(w => u.CoachBio.ToLower().Contains(w)) ) && (u.IsVerified == q.IsVerfied || q.IsVerfied != 1) && (u.CoachBodybuilding == q.CoachBodybuilding || q.CoachBodybuilding != 1) && (u.CoachClasses == q.CoachClasses || q.CoachClasses != 1) && (u.CoachCrossfit == q.CoachCrossfit || q.CoachCrossfit != 1) && (u.CoachDance == q.CoachDance || q.CoachDance != 1) && (u.CoachMasseuse == q.CoachMasseuse || q.CoachMasseuse != 1) && (u.CoachNutrition == q.CoachNutrition || q.CoachNutrition != 1) && (u.CoachOlympicLifting == q.CoachOlympicLifting || q.CoachOlympicLifting != 1) && (u.CoachOneOnOne == q.CoachOneOnOne || q.CoachOneOnOne != 1) && (u.CoachOnlineAvailable == q.CoachOnlineAvailable || q.CoachOnlineAvailable != 1) && (u.CoachOnlineOnly == q.CoachOnlineOnly || q.CoachOnlineOnly != 1) && (u.CoachOther == q.CoachOther || q.CoachOther != 1) && (u.CoachPhysio == q.CoachPhysio || q.CoachPhysio != 1) && (u.CoachPowerlifting == q.CoachPowerlifting || q.CoachPowerlifting != 1) && (u.CoachProgramOnly == q.CoachProgramOnly || q.CoachProgramOnly != 1) && (u.CoachStrongman == q.CoachStrongman || q.CoachStrongman != 1) && (u.CoachWeightLoss == q.CoachWeightLoss || q.CoachWeightLoss != 1) ) select u); int total = coaches.Count(); CityGeo city = await db.CityGeo.FindAsync(q.CityID); if (city != null) {//sort by distance first if city selected GeoAPI.Geometries.IGeometryFactory geometryFactory = NtsGeometryServices.Instance.CreateGeometryFactory(srid: 4326); GeoAPI.Geometries.IPoint cityLocation = geometryFactory.CreatePoint(new GeoAPI.Geometries.Coordinate((double)city.Latitude, (double)city.Longitude)); coaches = coaches.Where(x => x.Latitude.HasValue) .OrderBy(x => new GeoAPI.Geometries.Coordinate(x.Latitude.Value, x.Longitutde.Value).Distance(cityLocation.Coordinate)) .ThenByDescending(x => x.CreationDate); } else if (!string.IsNullOrEmpty(k)) {//else sort by keyword relevance only coaches = coaches .OrderByDescending(x => !string.IsNullOrEmpty(x.FirstName) && x.FirstName.ToLower().StartsWith(k)) .ThenByDescending(x => x.CreationDate); } else {//else sort by rating coaches = coaches.OrderByDescending(x => x.AverageRating); } coaches = coaches.Skip(pageNum * takeAmount).Take(takeAmount); if (coaches.Count() == 0) { return(new HttpResult(true, new { coaches = new List <UserPublic>(), total }, "")); } else { return(new HttpResult(true, new { coaches = coaches.Where(x => x != null).AsEnumerable().Select(s => new UserPublic(s, false)).ToList(), total }, "")); } } catch (Exception e) { var rawData = db.User.ToList(); return(new HttpResult(false, null, Functions.ErrorMessage(e))); } }