I have a two points describing a rectangle:
a Northeast Lat/Long and a Southwest Lat/Long.
What will be the correct and efficient way to generate a simple rectangle entity that can be stored in a DbGeography field?
Note that later on I would like to use that field to determine if a POINT is inside this Rectangle.
I realize I should use DbGeography.FromText(...) methods, but I'm not sure how.
The FromText method expects a WKT representation, in this case for a polygon:
Something like this should do the trick:
DbGeography box = DbGeography.FromText(
string.Format("POLYGON(({0} {1}, {0} {2}, {3} {2}, {3} {1}, {0} {1}))",
nwLongitude,
nwLatitude,
seLatitude,
seLongitude), 4326);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With