Download presentation
Presentation is loading. Please wait.
Published byJacob Neal Modified over 6 years ago
1
Using GIS in Postgres – Part 2 Real World Examples of PostGIS
By Lloyd Albin Seattle Postgres Users Group (SeaPUG)
2
Common Use for GIS Data Many website need to find all of y within x miles of z. Examples: Groupon.com - Find all of ad’s within x miles of home/work/city. Limos.com - Find all of limo companies within x miles of pickup. Maps.google.com - Find all business’s within x miles of address/city. In this demo we will be using a charter airlines quoting system that uses the same math as the above examples.
3
Challenger 601-3A - Performance
Runway length can vary based on temperature and weight. Sodona, AZ airport, while can support this aircraft, you can not take off during the heat of the day for a long flight. Max Fuel Range (nm) Max Payload Range (nm) Long Range Cruise Speed (nmph) Min Runway Length (ft) Fuel Max Pax Rate (hr) 3,370 2,182 425 2,850 Jet A 12 $10,000
4
The Math The great circle distance d between two points with coordinates {lat1,lon1} and {lat2,lon2} is given by: d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2)) A mathematically equivalent formula, which is less subject to rounding error for short distances is: d=2*asin(sqrt((sin((lat1-lat2)/2))^2 + cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))^2)) Convert longitude and latitude to radians (multiply lat/lon by pi/180) Convert radians to nautical miles (multiply d by 180*60/pi())
5
Normal SQL Query Airport Name Identifier Distance (nm) Hours Rate
SELECT d.airportname, d.identifier, (2*asin(sqrt((sin(((o.lat*pi()/180)-(d.lat*pi()/180))/2))^2+cos((o.lat*pi()/180))*cos((d.lat*pi()/180))*(sin(((o.lon*pi()/180)- (d.lon*pi()/180))/2))^2)))*180*60/pi() AS distance_nm, ((2*asin(sqrt((sin(((o.lat*pi()/180)-(d.lat*pi()/180))/2))^2+cos((o.lat*pi()/180))*cos((d.lat*pi()/180))*(sin(((o.lon*pi()/180)- (d.lon*pi()/180))/2))^2)))*180*60/pi())/400 AS hours, ((2*asin(sqrt((sin(((o.lat*pi()/180)-(d.lat*pi()/180))/2))^2+cos((o.lat*pi()/180))*cos((d.lat*pi()/180))*(sin(((o.lon*pi()/180)- (d.lon*pi()/180))/2))^2)))*180*60/pi())/400*10000 AS rate FROM flights.airports AS o, flights.airports AS d WHERE o.identifier = 'KBLI' AND d.identifier <> 'KBLI' AND d.jet = 1 AND d.runwaylength > 5000 AND (2*asin(sqrt((sin(((o.lat*pi()/180)-(d.lat*pi()/180))/2))^2+cos((o.lat*pi()/180))*cos((d.lat*pi()/180))*(sin(((o.lon*pi()/180)- (d.lon*pi()/180))/2))^2)))*180*60/pi() < 3000 ORDER BY 3 Airport Name Identifier Distance (nm) Hours Rate Las Vegas/Mc Carran Intl,NV KLAS $20,723.46
6
Airports within Range of Bellingham
We did not take into account the 2 hour fuel reserve that is required. I believe that there is also special fuel requirement when flying over water.
7
How to add geom to Database
ALTER TABLE flights.airports ADD COLUMN geom public.geography; UPDATE flights.airports SET geom = ST_SetSRID(ST_Point(lon, lat),4326)::geography; 4326 Longitude/Latitude based on WGS Meter based on WGS 84 WGS 84 = World Geodetic System dated 1984
8
PostGIS Query SELECT d.airportname, d.identifier, ST_Distance(o.geom, d.geom)/1000 AS distance_km, ST_Distance(o.geom, d.geom)/1000* AS distance_nm, ST_Distance(o.geom, d.geom)/1000* /400 AS hours, ST_Distance(o.geom, d.geom)/1000* /400*10000 AS rate FROM flights.airports AS o, flights.airports AS d WHERE o.identifier = 'KBLI' AND d.identifier <> 'KBLI' AND d.jet = 1 AND d.runwaylength > 5000 AND ST_Distance(o.geom, d.geom)/1000* < 3000 ORDER BY 4 nm difference between the two methods. Airport Name Identifier Distance (km) Distance (nm) Hours Rate Las Vegas/Mc Carran Intl,NV KLAS $20,728.16
9
Airports within Washington State
10
True Rates with Taxes Item Rate Amount Flight $10,000 per flight hour
$20,728.16 Federal Excise Tax 7.5% $1,554.61 Domestic Segment Tax $3.90 per passenger x 12 passengers $46.80 Grand Total $22,329.57 Most Quoting software bases the rates on per hour, nautical mile, or mile. The Federal Excise Tax is also applied to Food, Stewards, Ground Transportation, etc. No segment tax at rural airports International Segment Tax of $17.20 per passenger.
11
Other GeoSpatial Downloads
12
References Aircraft Photo A-ER/ htm Aircraft Specifications Great Circle Math and other aircraft related math Airport Database Spatial Reference: EPSG Projection WGS 84 IRS Publication 720 – Flight Taxes
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.