예제 #1
0
 public HighbankCommunityCentreNottingham()
 {
     Name = "Highbank Community Centre, Nottingham";
     LatitudeLongitude = new LatitudeLongitude(52.89656014861801, -1.1813903633751395);
     Address           = "Highbank Community Centre, Farnborough Road, Clifton, Nottingham, Nottinghamshire NG11 9DG";
     PostCode          = "NG11 9DG";
 }
 public GreenfieldsPrimarySchoolKettering()
 {
     Name = "Greenfields Primary School, Kettering";
     LatitudeLongitude = new LatitudeLongitude(52.385545, -0.725149);
     Address           = "Greenfields Primary School, Highfield Road, Kettering, NN14 1JS";
     PostCode          = "NN14 1JS";
 }
예제 #3
0
파일: GeoSource.cs 프로젝트: Levrum/Levrum
        public Dictionary <string, object> GetPropertiesForLatLon(LatitudeLongitude latLon)
        {
            Dictionary <string, object> output = new Dictionary <string, object>();

            List <AnnotatedObject <ComplexPolygon> > cPolys = GetComplexPolysFromFile();

            double[]       xyPoint            = Converter.ConvertLatLonToXY(latLon);
            ComplexPolygon lastContainingPoly = null;

            foreach (AnnotatedObject <ComplexPolygon> cPoly in cPolys)
            {
                if (cPoly.Object.Contains(xyPoint[0], xyPoint[1]))
                {
                    foreach (KeyValuePair <string, object> kvp in cPoly.Data)
                    {
                        if (output.ContainsKey(kvp.Key))
                        {
                            LogHelper.LogMessage(LogLevel.Warn, string.Format("Discarding data {0}={1} at coordinates {2},{3}", kvp.Key, output[kvp.Key], latLon.Latitude, latLon.Longitude));
                        }
                        else
                        {
                            output[kvp.Key] = kvp.Value;
                        }
                    }
                    lastContainingPoly = cPoly.Object;
                }
            }

            return(output);
        }
예제 #4
0
 public TheLifeChurchLichfield()
 {
     Name = "The Life Church, Lichfield";
     LatitudeLongitude = new LatitudeLongitude(52.693922, -1.819607);
     Address           = "The Life Church, Netherstowe, Lichfield, Staffordshire, WS13 6TS";
     PostCode          = "WS13 6TS";
 }
예제 #5
0
 public SilebyCommunityCentre()
 {
     Name = "Sileby Community Centre, Sileby";
     LatitudeLongitude = new LatitudeLongitude(52.730248, -1.110305);
     Address           = "Sileby Community Centre, High ST, Sileby, Leicester. LE12 7RX";
     PostCode          = "LE12 7RX";
 }
        public static void Example()
        {
            Console.WriteLine("-- Easting/ Nothing to Latitude Longitude --");
            // Given an easting and northing in metres (see text)
            const double easting  = 319267;
            const double northing = 175189;

            Console.WriteLine("INPUT");
            Console.WriteLine($"Easting: {easting}");
            Console.WriteLine($"Northing: {northing}");

            // Convert to Cartesian
            Cartesian cartesian = Convert.ToCartesian(new Airy1830(),
                                                      new BritishNationalGrid(),
                                                      new EastingNorthing(easting, northing));

            Cartesian wgsCartesian = Transform.Osgb36ToEtrs89(cartesian); //ETRS89 is effectively WGS84

            LatitudeLongitude wgsLatLong = Convert.ToLatitudeLongitude(new Wgs84(), wgsCartesian);

            Console.WriteLine("OUTPUT");
            Console.WriteLine($"Latitude: {wgsLatLong.Latitude}");
            Console.WriteLine($"Longitude: {wgsLatLong.Longitude}");
            Console.WriteLine();
        }
예제 #7
0
 public GrammarSchoolLoughborough()
 {
     Name = "Grammar School, Loughborough";
     LatitudeLongitude = new LatitudeLongitude(52.765786, -1.199820);
     Address           = "LOUGHBOROUGH Grammar School, Leicester Road , Loughborough , Leicestershire, LE11 2AQ";
     PostCode          = "LE11 2AQ";
 }
예제 #8
0
파일: OsmFile.cs 프로젝트: Levrum/Levrum
        public List <OSMWay> GetWaysIntersectingLine(LatitudeLongitude point1, LatitudeLongitude point2)
        {
            List <OSMWay> output = new List <OSMWay>();

            try
            {
                foreach (OSMWay way in Ways)
                {
                    if (way.BoundingBox.IntersectsLine(point1, point2))
                    {
                        for (int i = 0; i < way.NodeReferences.Count - 1; i++)
                        {
                            OSMNode thisNode, thatNode;
                            if (!NodesById.TryGetValue(way.NodeReferences[i], out thisNode) || !NodesById.TryGetValue(way.NodeReferences[i + 1], out thatNode))
                            {
                                continue;
                            }

                            Point2 intersectionPoint = LineSegment2.Intersection(point1, point2, thisNode.Location, thatNode.Location);
                            if (intersectionPoint != null)
                            {
                                output.Add(way);
                            }
                        }
                    }
                }

                return(output);
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex, "Error getting intersecting ways", true);
            }
            return(output);
        }
예제 #9
0
        /// <summary>
        /// Verify if a Seekios is in a zone when configuring a mode zone
        /// </summary>
        /// <param name="seekiosPosition"></param>
        /// <param name="zone"></param>
        /// <returns></returns>
        public bool IsSeekiosInZone(LatitudeLongitude seekiosPosition, List <LatitudeLongitude> zone)
        {
            int    i     = 0;
            double angle = 0;
            //	LatLng p1 = new LatLng(0, 0);
            //	LatLng p2 = new LatLng(0, 0);

            var p1 = new CLLocationCoordinate2D(0, 0);
            var p2 = new CLLocationCoordinate2D(0, 0);

            int n = zone.Count();

            for (i = 0; i < n; i++)
            {
                p1.Latitude  = zone[i].Latitude - seekiosPosition.Latitude;
                p1.Longitude = zone[i].Longitude - seekiosPosition.Longitude;
                p2.Latitude  = zone[(i + 1) % n].Latitude - seekiosPosition.Latitude;
                p2.Longitude = zone[(i + 1) % n].Longitude - seekiosPosition.Longitude;
                angle       += GetAngle2D(p1.Latitude, p1.Longitude, p2.Latitude, p2.Longitude);
            }

            if (Math.Abs(angle) < PI)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #10
0
 public NewarkShowground()
 {
     Name = "Newark Showground, Newark";
     LatitudeLongitude = new LatitudeLongitude(53.098709, -0.768302);
     Address           = "Lady Eastwood Pavilion, Newark Showground, Drove Lane, Newark, Nottinghamshire NG24 2NY";
     PostCode          = "NG24 2NY";
 }
예제 #11
0
 public TheNationalBreweryCentre()
 {
     Name = "The National Brewery Centre, Burton Upon Trent";
     LatitudeLongitude = new LatitudeLongitude(52.807752, -1.631799);
     Address           = "The National Brewery Centre, Horninglow Street, Burton Upon Trent, DE14 1NG";
     PostCode          = "DE14 1NG";
 }
 public TheSummitCentreKirkby()
 {
     Name = "The Summit Centre, Kirkby";
     LatitudeLongitude = new LatitudeLongitude(53.104722, -1.242296);
     Address           = "The Summit Centre, Pavilion Road Off Lowmoor Road, Kirkby-In-Ashfield, Nottinghamshire, NG17 7LL";
     PostCode          = "NG17 7LL";
 }
        public void TestOrthodromicProjection()
        {
            LatitudeLongitude testLL  = new LatitudeLongitude(45, 30);
            LatitudeLongitude testLLV = new LatitudeLongitude(testLL);

            Assert.AreEqual(testLL.Lon, testLLV.Lon, 0.0000001, "test constructeur LatitudeLongitude(Vector)");
            Assert.AreEqual(testLL.Lat, testLLV.Lat, 0.0000001, "test constructeur LatitudeLongitude(Vector)");

            LatitudeLongitude observer = new LatitudeLongitude(30, -50);

            AltitudeAzimuth   aa1   = new AltitudeAzimuth(80.0, 0.0); //10° to the North
            LatitudeLongitude test1 = observer.OrthodromicProjection(aa1);

            Assert.AreEqual(40.0, test1.Lat, 0.00001, "Lat 30° + 10° = 40°");

            AltitudeAzimuth   aa2   = new AltitudeAzimuth(80.0, 180); //10° to the South
            LatitudeLongitude test2 = observer.OrthodromicProjection(aa2);

            Assert.AreEqual(20.0, test2.Lat, 0.00001, "Lat 30° - 10° = 20°");

            LatitudeLongitude observer2 = new LatitudeLongitude(-30, -50);

            LatitudeLongitude test3 = observer2.OrthodromicProjection(aa2);

            Assert.AreEqual(-40.0, test3.Lat, 0.00001, "Lat -30° - 10° = -40°");
            Assert.AreEqual(observer2.Lon, test3.Lon, 0.00001, "10° to the South does not modify Longitude");

            LatitudeLongitude star = new LatitudeLongitude(30, -100);
            AltitudeAzimuth   aa   = new AltitudeAzimuth(observer, star);
            //Assert.AreEqual(90.0, aa.Az, 0.000001, "Orthodromic azimuth");
            LatitudeLongitude result = observer.OrthodromicProjection(aa);

            Assert.AreEqual(result.Lat, star.Lat, 0.0001, "Latitudes");
            Assert.AreEqual(result.Lon, star.Lon, 0.0001, "Longitudes");
        }
예제 #14
0
 public SherwoodCommunityCentreSherwood()
 {
     Name = "Sherwood Community Centre, Sherwood";
     LatitudeLongitude = new LatitudeLongitude(52.985928, -1.143651);
     Address           = "Sherwood Community Centre,  Mansfield Road, Sherwood, Nottingham, NG5 3FN";
     PostCode          = "NG5 3FN";
 }
 public HeanorMinersWelfareIlkeston()
 {
     Name = "Heanor Miners Welfare, Ilkeston";
     LatitudeLongitude = new LatitudeLongitude(53.010025, -1.351558);
     Address           = "Heanor Miners Welfare, Ilkeston Road, Heanor, Derbyshire DE75 7DT";
     PostCode          = "DE75 7DT";
 }
        public static DataSet GenerateDistances(DataSet ds, LatitudeLongitude centreOfPostcode, DistanceCalculator distanceCalculator)
        {
            if (ds == null)
            {
                throw new ArgumentNullException("ds");
            }
            if (distanceCalculator == null)
            {
                throw new ArgumentNullException("distanceCalculator");
            }

            using (DataColumn dcK = new DataColumn("Kilometres", Type.GetType("System.Double")))
            {
                using (DataColumn dcM = new DataColumn("Miles", Type.GetType("System.Double")))
                {
                    ds.Tables[0].Columns.Add(dcK);
                    ds.Tables[0].Columns.Add(dcM);
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        var latLongInDataRow = new LatitudeLongitude(Convert.ToDouble(dr["Latitude"].ToString(), CultureInfo.InvariantCulture), Convert.ToDouble(dr["Longitude"].ToString(), CultureInfo.InvariantCulture));
                        var kilometres       = distanceCalculator.DistanceBetweenTwoPoints(centreOfPostcode, latLongInDataRow) / 1000;
                        dr["Kilometres"] = kilometres;
                        dr["Miles"]      = Math.Round((kilometres * 0.6214), 2);
                    }
                    ds.AcceptChanges();
                    return(ds);
                }
            }
        }
예제 #17
0
 public static LatitudeLongitude Lerp(LatitudeLongitude valueA, LatitudeLongitude valueB, double percentage)
 {
     return(new LatitudeLongitude(
                (valueA.latitude * (1.0 - percentage)) + (valueB.latitude * percentage),
                (valueA.longitude * (1.0 - percentage)) + (valueB.longitude * percentage)
                ));
 }
 public TheForrayanCentreHinckley()
 {
     Name = "The Forrayan Centre, Hinckley";
     LatitudeLongitude = new LatitudeLongitude(52.543976, -1.36615364);
     Address           = "The Forrayan Centre, St Peters R.C. Church, Leicester Road, Hinckley, Leicestershire LE10 1LS";
     PostCode          = "LE10 1LS";
 }
예제 #19
0
        public async Task ConvertOSEastingsNorthingsDataToLatLongUK()
        {
            var       filesToProcess = Directory.GetFiles(ukRawDataFolder);
            Stopwatch st             = new Stopwatch();

            st.Start();

            foreach (var file in filesToProcess)
            {
                try
                {
                    var contentRows = _csvParser.ReadCsvFromFile(file);

                    List <LocationLatLng> latLongRows = new List <LocationLatLng>();

                    foreach (var row in contentRows)
                    {
                        if (String.IsNullOrWhiteSpace(row))
                        {
                            continue;
                        }

                        var split = row.Split(',');

                        var postcode = split[0];
                        Console.WriteLine(st.ElapsedMilliseconds + ":" + postcode);
                        var easting  = double.Parse(split[2]);                        // No Try here. We want it to bomb out if there's an error.
                        var northing = double.Parse(split[3]);

                        // A postcode covers multiple houses.
                        // As it covers a fairly wide area, we don't need to go ultra-fine in the conversion.
                        LatitudeLongitude latLong = _geoUKHelper.ConvertEastNorthToLatLong_LowerAccuracyFast(easting, northing);

                        var gmaps = string.Format("https://www.google.co.uk/maps/@{0},{1},19z", Math.Round(latLong.Latitude, 6), Math.Round(latLong.Longitude, 6));

                        // We don't need more than 6 decimal places (11.1cm accuracy)
                        // https://gis.stackexchange.com/questions/8650/measuring-accuracy-of-latitude-and-longitude?newreg=5f6bf4ba81534a7ea34606ceceb00b35
                        var latRounded  = Math.Round(latLong.Latitude, 6);
                        var longRounded = Math.Round(latLong.Longitude, 6);

                        LocationLatLng postcodeZipLatLong = new LocationLatLng(postcode, latRounded, longRounded);
                        latLongRows.Add(postcodeZipLatLong);
                    }

                    FileInfo fi          = new FileInfo(file);
                    var      newFilePath = Path.Combine(ukLatLongDataFolder, fi.Name);

                    await _postcodeZipLatLongMethods.SavePostcodeZipLatLongToFile(newFilePath, latLongRows);

                    // Clear the data for quicker garbage disposal.
                    latLongRows.Clear();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    Console.ReadLine();
                }
            }
        }
예제 #20
0
 public LoughboroughGCR()
 {
     Name = "Loughborough, Great Central Railway";
     LatitudeLongitude = new LatitudeLongitude(52.769585, -1.196141);
     Address           = "Loughborough Central Station, LE11 1RW";
     PostCode          = "LE11 1RW";
     ShortName         = "Loughborough Station";
 }
예제 #21
0
 public LeicesterNorthStationGCR()
 {
     Name = "Leicester North Station/Greenacres, Great Central Railway";
     LatitudeLongitude = new LatitudeLongitude(52.66786857498172, -1.1333491304025842);
     Address           = "Leicester North Station, The Sidings, Leicester LE4 3BA";
     PostCode          = "LE4 3BA";
     ShortName         = "Leicester North Station";
 }
예제 #22
0
 public QuornWoodhouseStationGCR()
 {
     Name = "Quorn & Woodhouse Station, Great Central Railway";
     LatitudeLongitude = new LatitudeLongitude(52.74055736337358, -1.1877129573853749);
     Address           = "Woodhouse Rd, Quorn, Loughborough LE12 8AG";
     PostCode          = "LE12 8AG";
     ShortName         = "Quorn & Woodhouse Station";
 }
        internal WeatherResult ToWeatherResult(LocationResult location)
        {
            ITemperature      temperature = new DegreesFahrenheit(this.Temperature.Value);
            WindSpeed         windSpeed   = new WindSpeed(new MilesPerHour(this.Wind.Speed.Imperial.Value), this.Wind.Direction.Degrees);
            LatitudeLongitude latLong     = new LatitudeLongitude(location.GeoPosition.Latitude, location.GeoPosition.Longitude);

            return(new WeatherResult(temperature, latLong, windSpeed));
        }
 public RothleyStationGCR()
 {
     Name = "Rothley Station, Great Central Railway";
     LatitudeLongitude = new LatitudeLongitude(52.70459550090345, -1.1598164015656793);
     Address           = "Station Rd, Leicester LE7 7LA";
     PostCode          = "LE7 7LA";
     ShortName         = "Rothley Station";
 }
 public RushcliffeHaltGCR()
 {
     Name = "Rushcliffe Halt, East Leake, Great Central Railway";
     LatitudeLongitude = new LatitudeLongitude(52.84383440266633, -1.1821199020700344);
     Address           = "Gotham Road, East Leake, Nottinghamshire";
     PostCode          = string.Empty;
     ShortName         = "Rushcliffe Halt";
 }
예제 #26
0
    // Update is called once per frame
    void Update()
    {
        LatitudeLongitude relativeLatLongDelta = this.latLong - this.centerPosition;

        Vector3 localPos = new Vector3((float)(relativeLatLongDelta.longitude * this.scalar1), ((float)(relativeLatLongDelta.latitude * this.scalar2)), 0);

        this.referenceCube.transform.localPosition = localPos;
    }
예제 #27
0
파일: Convert.cs 프로젝트: fossabot/GeoUK
        public static Cartesian ToCartesian(Ellipsoid ellipsoid, Projection projection, EastingNorthing coordinates)
        {
            LatitudeLongitude latLongCoordinates = ToLatitudeLongitude(
                ellipsoid,
                projection,
                coordinates);

            return(ToCartesian(ellipsoid, latLongCoordinates));
        }
예제 #28
0
파일: OsmFile.cs 프로젝트: Levrum/Levrum
        private void findConnectedIntersections()
        {
            foreach (OSMWay way in Ways)
            {
                if (way.NodeReferences.Count < 2)
                {
                    continue;
                }

                if (!way.Tags.ContainsKey("highway") || !AcceptedRoadTypes.Contains(way.Tags["highway"]))
                {
                    continue;
                }

                bool              firstLoop = true;
                double            distSinceMatch = 0;
                LatitudeLongitude previousLoc = null;
                OSMIntersection   intersection = null, previousIntersection = null;
                foreach (string nodeId in way.NodeReferences)
                {
                    if (nodeId == "149232745" && previousIntersection != null && previousIntersection.ID == "149161225")
                    {
                        var str = "str";
                    }
                    OSMNode node;
                    if (!NodesById.TryGetValue(nodeId, out node))
                    {
                        int index = way.NodeReferences.IndexOf(nodeId);
                        way.NodeReferences.RemoveAt(index);
                        way.NodeDistances.RemoveAt(index);
                        continue;
                    }

                    if (!firstLoop)
                    {
                        distSinceMatch += previousLoc.DistanceFrom(node.Location);
                    }

                    previousLoc = node.Location;
                    firstLoop   = false;
                    if (Intersections.TryGetValue(nodeId, out intersection))
                    {
                        if (previousIntersection != null)
                        {
                            previousIntersection.ConnectedIntersectionDistances[nodeId] = distSinceMatch;
                            if (!way.Oneway)
                            {
                                intersection.ConnectedIntersectionDistances[previousIntersection.ID] = distSinceMatch;
                            }
                            distSinceMatch = 0;
                        }
                        previousIntersection = intersection;
                    }
                }
            }
        }
        public static WeatherResult ToResult(this WeatherData weatherData)
        {
            Kelvin kelvin = new Kelvin(weatherData.main.temp);

            LatitudeLongitude location = new LatitudeLongitude(weatherData.coord.lat, weatherData.coord.lon);

            WindSpeed windSpeed = new WindSpeed(new KilometersPerHour(weatherData.wind.speed), weatherData.wind.deg);

            WeatherResult result = new WeatherResult(kelvin, location, windSpeed);

            return(result);
        }
예제 #30
0
파일: Convert.cs 프로젝트: fossabot/GeoUK
        /// <summary>
        /// Converts latitude, longitude and ellipsoidal height coordinates to cartesian coordinates using the same ellipsoid.
        /// Please note this is not a transformation between ellipsoids.
        /// </summary>
        /// <param name="ellipsoid"></param>
        /// <param name="coordinates"></param>
        /// <returns></returns>
        public static Cartesian ToCartesian(Ellipsoid ellipsoid, LatitudeLongitude coordinates)
        {
            double lat    = ToRadians(coordinates.Latitude);
            double lon    = ToRadians(coordinates.Longitude);
            double height = coordinates.EllipsoidalHeight;

            double e2 = ellipsoid.EccentricitySquared;
            double a  = ellipsoid.SemiMajorAxis;

            double v = a / Math.Sqrt(1 - (e2 * Math.Pow(Math.Sin(lat), 2)));

            double x = (v + height) * Math.Cos(lat) * Math.Cos(lon);
            double y = (v + height) * Math.Cos(lat) * Math.Sin(lon);
            double z = ((1 - e2) * v + height) * Math.Sin(lat);

            return(new Cartesian(x, y, z));
        }