program GEO_Distance_BOX_WebScript_mapbox_Satellite_EKON21; //********************************************************************* // Computes distance between earth locations based on OpenStreetMap! #locs:255 //#sign:Max: MAXBOX10: 11/07/2017 15:36:18 //shows a REST call MAP GetGeoC() with RegEx validate and GEO distance formula //********************************************************************* (*RRRR EEEEEE AAAA DDDDD MM MM EEEEEE RR RR EE AA AA DD DD MMMM MMMM EE RRRRR EEEE AAAAAA DD DD MM MMM MM EEEE RR RR EE AA AA DD DD MM M MM EE RR RR EEEEEE AA AA DDDDD MM M MM EEEEEE *) //http://www.rosettacode.org/wiki/Haversine_formula#Delphi ////////////////////////////////GEO CoorD Distance///////////////////////////// //EKON20 Token: // pk.eyJ1IjoibWF4Ym94IiwiYSI6ImNpdHkxeXplaDAwMzkyenAxcXBhdXNpcmcifQ.Zr-dpQ8uLP7TKLcVwyq_zg //default token: //pk.eyJ1IjoibWF4Ym94IiwiYSI6ImNpcWpubHVrZDAwZGZod2t4eGxxaHIybDkifQ.6SitTIIurXlwj3pVBeyhow {https://sourceforge.net/p/maxbox/news/2016/05/maxbox42-available/} //check with Ctrl W! Const GEOCoordREX = 'latitude: ''([\d\.-]+).* longitude: ''([\d\.-]+).*'; //ex.: latitude: '-37.8696164' longitude: '144.9819593' UrlMapQuestAPIReverse= 'http://open.mapquestapi.com/nominatim/v1/reverse.php?format=%s&json_callback=renderExampleThreeResults&lat=%s&lon=%s'; mapboxAPI = 'https://api.mapbox.com/geocoding/v5/mapbox.places/%s.json?country=%s'+ '&access_token=pk.eyJ1IjoibWF4Ym94IiwiYSI6ImNpcWpubHVrZDAwZGZod2t4eGxxaHIybDkifQ.6SitTIIurXlwj3pVBeyhow'; mapboxAPIMap5= 'https://api.mapbox.com/v4/mapbox.satellite/16.95,47.45,5,0/%dx%d.png128?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpbTgzcHQxMzAxMHp0eWx4bWQ1ZHN2NGcifQ.WVwjmljKYqKciEZIC3NfLA#4/46.210/7.45'; mapboxAPIMap6= 'https://api.mapbox.com/v4/mapbox.streets-satellite/7.45,46.95,15,0,5/%dx%d.png128?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpbTgzcHQxMzAxMHp0eWx4bWQ1ZHN2NGcifQ.WVwjmljKYqKciEZIC3NfLA#4'; mapboxAPIMap= 'https://api.mapbox.com/v4/mapbox.satellite/%.2f,%.2f,%.2f,0/%dx%d.png128?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpbTgzcHQxMzAxMHp0eWx4bWQ1ZHN2NGcifQ.WVwjmljKYqKciEZIC3NfLA#4/'; mapboxAPIMapDark= 'https://api.mapbox.com/v4/mapbox.dark/%.2f,%.2f,%.2f,0/%dx%d.png128?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpbTgzcHQxMzAxMHp0eWx4bWQ1ZHN2NGcifQ.WVwjmljKYqKciEZIC3NfLA#4/'; mapboxAPIMapDarkEKONKey= 'https://api.mapbox.com/v4/mapbox.comic/%.3f,%.3f,%.3f,0/%dx%d.png128?access_token=pk.eyJ1IjoibWF4Ym94IiwiYSI6ImNpdHkxeXplaDAwMzkyenAxcXBhdXNpcmcifQ.Zr-dpQ8uLP7TKLcVwyq_zg'; mapboxAPIMapStreet= 'https://api.mapbox.com/v4/mapbox.streets-satellite/%.2f,%.2f,%.2f,0,0/%dx%d.png128?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpbTgzcHQxMzAxMHp0eWx4bWQ1ZHN2NGcifQ.WVwjmljKYqKciEZIC3NfLA#4'; mapboxAPIMapStreet2= 'https://api.mapbox.com/v4/mapbox.streets/%.2f,%.2f,%.2f,0,0/%dx%d.png128?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpbTgzcHQxMzAxMHp0eWx4bWQ1ZHN2NGcifQ.WVwjmljKYqKciEZIC3NfLA#4'; { # retrieve a map at -122.4241 longitude, 37.78 latitude, # zoom 14.24, bearing 0, and pitch 60. The map # will be 600 pixels wide and 600 pixels high curl "https://api.mapbox.com/styles/v1/mapbox/streets-v8/static/-122.4241,37.78,14.25,0,60/600x600" } UrlWeatherReport25= 'http://api.openweathermap.org/data/2.5/weather?q=%s&units=metric&APPID'+ '=55013bf3d09cfb0619989a00ed5bed09'; function GetGeoInfo5(const location,country: string; const UrlGeoLookupInfo: string): string; var lStream: TStringStream; begin lStream:= TStringStream.Create(''); try try HttpGet(Format(UrlGeoLookupInfo,[location,country]), lStream); //WinInet Circuit except //lHTTP.Get1(Format(UrlGeoLookupInfo2,[IpAddress]), lStream); //if something wrong try using backup server. writeln(ExceptionToString(ExceptionType, ExceptionParam)); end; lStream.Seek(0,0); result:= 'GEO_CodeDataMapOut: '+UTF8ToString(lStream.ReadString(lStream.Size)); finally lStream.Free; end; end; function GetGeoInfoMap(const location,country, apath: string; asize: integer; const UrlGeoLookupInfo: string): string; var pngStream: TMemoryStream; begin pngStream:= TMemoryStream.Create; try HttpGet(Format(UrlGeoLookupInfo,[asize,asize]), pngStream); //WinInet Circuit except //lHTTP.Get1(Format(UrlGeoLookupInfo2,[IpAddress]), lStream); //if something wrong try using backup server. writeln(ExceptionToString(ExceptionType, ExceptionParam)); end; with TLinearBitmap.Create do try pngStream.Position:= 0; LoadFromStream2(pngStream,'PNG'); SaveToFile(apath); OpenDoc(apath); finally Dispose; Free; pngStream.Free; end; end; function GetGeoInfoMap4save(const lat,lon, zoom: double; asize: integer; const UrlGeoLookupInfo, apath: string): string; var pngStream: TMemoryStream; begin pngStream:= TMemoryStream.Create; try HttpGet(Format(UrlGeoLookupInfo,[lon,lat,zoom, asize,asize]),pngStream); //WinInet Circuit except //lHTTP.Get1(Format(UrlGeoLookupInfo2,[IpAddress]), lStream); //if something wrong try using backup server. writeln(ExceptionToString(ExceptionType, ExceptionParam)); end; with TLinearBitmap.Create do try pngStream.Position:= 0; LoadFromStream2(pngStream,'PNG'); paintToCanvas(getform(asize+30,asize+40).canvas, Rect(25,25,Width,Height),false); SaveToFile(apath); finally Dispose; Free; pngStream.Free; end; end; procedure letGEOCoord(apistr: string); begin with TRegExpr.Create do try Expression:= GEOCoordREX; if Exec(apistr) then PrintF('GEO REXT live: '+ 'lat %sº in long %sº ',[Match[1],Match[2]]); writeln(Match[1]+': '+Match[2]) finally Free; end; end; function GEOCoord2Point(apistr: string): TFloatPoint; begin with TRegExpr.Create do try Expression:= GEOCoordREX; if Exec(apistr) then begin result.x:= strtofloat(Match[1]) result.y:= strtofloat(Match[2]) end; finally Free; end; end; const DIAMETER = 2 * 6372.8; //haversine(lat1,lon1,lat2,lon2) function HaversineDist(th1, ph1, th2, ph2:double):double; var dx, dy, dz:double; begin ph1 := degtorad(ph1 - ph2); th1 := degtorad(th1); th2 := degtorad(th2); dz := sin(th1) - sin(th2); dx := cos(ph1) * cos(th1) - cos(th2); dy := sin(ph1) * cos(th1); Result := arcsin(sqrt(sqr(dx) + sqr(dy) + sqr(dz))/2) * DIAMETER; end; //http://www.rosettacode.org/wiki/Haversine_formula#Delphi function GetGEONameDistance2(loc1, loc2: string): double; var latf,lonf, latf1,lonf1: Double; geocode, geocode2: string; begin if isInternet then begin geocode:= GetGeoCode('xml','',loc1, false); latf:= GEOCoord2Point(geocode).x lonf:= GEOCoord2Point(geocode).y geocode2:= GetGeoCode('xml','',loc2, false); latf1:= GEOCoord2Point(geocode2).x lonf1:= GEOCoord2Point(geocode2).y result:= HaversineDist(latf,lonf,latf1, lonf1); end else writeln('No Internet Connection found'); end; const ARAD = 0.000008998719243599958; function testlabdistance: double; begin result:= sqrt(power(36.12 - 33.94, 2) + power(-86.67 - -118.4, 2)) / ARAD; end; var geocode, geocode2: string; latf, longf, distres, zoomf: Double; begin //@main //ref 2887.25995060711 Writeln('Haversine distance1: ' +floattostr(HaversineDist(36.12, -86.67, 33.94, -118.4))+' km.'); Writeln('Haversine distance2: ' +format('%.2f ',[HaversineDist(36.12, -86.67, 33.94, -118.4)])+' km.'); writeln(floattostr(testlabdistance)) writeln('DegToDmsStr lat: '+DegToDmsStr(50.9385758,4)) writeln('DegToDmsStr lon: '+DegToDmsStr(6.96161043239216,4)) //Function DMS2Extended( const Degs, Mins, Secs : Extended) : Extended 5444: //Procedure Extended2DMS( const X : Extended; var Degs, Mins, Secs : Extended) //call to the def function: PrintF('distance bern-cologne coord direct: %.2f km', [GetGEONameDistance2('46.95 7.45','50.94 6.95')]); PrintF('dist bern-vienna church1: %.2f km', [GetGEONameDistance2('church cathedral bern','church cathedral vienna')]); PrintF('dist bern-vienna church2: %.2f km', [GetGEONameDistance2('cathedral bern','cathedral vienna')]); PrintF('dist bern-vienna church3: %.2f km', [GetGEONameDistance2('bern switzerland','vienna austria')]); PrintF('dist bern-melbourne: %.2f km', [GetGEONameDistance2('bern switzerland','melbourne victoria australia')]); { PrintF('dist nashville-los angeles: %.2f km', [GetGEONameDistance2('Nashville, TN, USA','Los Angeles, CA, USA')]); PrintF('dist bern-gomera: %.2f km', [GetGEONameDistance2('bern switzerland','Gomera spain')]); PrintF('dist bern-montreux: %.2f km', [GetGEONameDistance2('bern switzerland','montreux switzerland')]); } //be aware of minus sign - solved in RegEx //wolfram Result: 16425 km (kilometers) bern-melbourne //writeln(GetGeoCode('xml',ExePath+'', 'melbourne australia', false)); //} writeln('DegToDmsStr lat: '+DegToDmsStr(46.9570806,3)) writeln('DegToDmsStr lon: '+DegToDmsStr(7.45880536873668,3)) writeln('DegToDmsStr lon: '+DegToDmsStr(7.45880536,3)) writeln('DegToDmsStr lon: '+DegToDmsStr(7.45880536873668,5)) writeln('places API: '+GetGeoInfo5('station cologne','de',mapboxAPI)) //GetGeoInfoMap('cologne','de',ExePath+'mX4mapbox.png',550,mapboxAPIMap) if IsInternet then GetGeoInfoMap4save(46.632,14.142,16,680,mapboxAPIMapDarkEKONKey, ExePath+'mX4mapbox_poertschach_comic.png') End. Doc: website. Mapbox Static API Mapbox also provides a Static API for creating static images from your map styles. Provide your style ID, access token, and a few more parameters and you can display static images directly by making requests in your application. https://www.academia.edu/26964578/mapbox_REST_API_GEO_service.pdf https://api.mapbox.com/v4/mapbox.streets/1/0/0.png" // procedure PaintToCanvas(Canvas: TCanvas; const Dest: TRect; HalftoneStretch: Boolean=False); // procedure StretchDIBits(DC: THandle; const Dest: TRect; HalftoneStretch: Boolean=False); Latitude and longitude are a pair of numbers (coordinates) used to describe a position on the plane of a geographic coordinate system. The numbers are in decimal degrees format and range from -90 to 90 for latitude and -180 to 180 for longitude. For example, Washington DC has a latitude 38.8951 and longitude -77.0364. In API calls you’ll often see the numbers placed together and separated by a comma: 38.8951,-77.0364. One common problem is mixing up the latitude and longitude. Some tools and APIs format longitude,latitude while others use latitude,longitude. ifs=: (fa@] + fm@] +/ .* [) prob getPoints=: ifs^:(<200000) plotFern=: 'dot;grids 0 0;tics 0 0;labels 0 0;color green' plot ;/@|: plotFern getPoints 0 0 [[File:Barnsley_farn_white.PNG]] just inside maxbox ____ ___ _ ____ _ _ _ | _ \ | _| | | | _ \ | | | | | | | | . | | |_ | | | |_| | | |_| | | | | | | | | _| | | | __/ | _ | | | | |_. | | |_ | |__ | | | | | | | | |____/ |___| |____| |_| |_| |_| |_| ----code_cleared_checked---- Fazit: https://www.mapbox.com/map-feedback/#mapbox.streets/11.458/46.089/10 Mit der mapbox Open Source Platform hat man ein Toolset und diverse REST APIs zugleich, die man schlicht zur Next Generation zählen darf. Immer mehr Apps der Geoinformationstechnologie basieren auf Basis von HTML5, CSS3 und JavaScript im Umfeld von sog. Responsive Design. Mit den modularen APIs, vor allem Static, Geocoding, Distance und Map Matching ist man breit augestellt, was auch die plattformunabhängige Entwicklung fördert. Auch mit dem durchdachten Upload API wird man mit dem Stagen von Daten in eine Cloud wie S3 nicht alleine gelassen. Das eigene Tool mapbox Studio hilft beim Editieren von neuen Layern oder ausgefeiltem, interaktivem Kartenmaterial. Das Tool vereint Flexibilität, moderner Look und einfache Bedienung in einem, in der Basic Version sogar kostenlos. Für mich ein Highlight ist der Satellite Layer kombiniert mit dem Static API. Mapbox kann auf unterschiedliche Auflösungen in unterschiedlichen Gebieten auch in Detailkarten mit Zoomstufen reagieren. Man darf teilweise DigitalGlobe-Bilder nutzen und erweitern, die genaue Rechtslage ergibt sich aber nicht aus der Veröffentlichung. Mit Mapbox lassen sich also Karten auf einfache Weise in Anwendungen oder Artikel integrieren. Die Verwendung setzt ein Account voraus und der Preis ist volumenbasiert. Mit der App lassen sich nicht nur Orte, sondern auch ganze Strecken und Areale deutlich machen um der Erde ein neues Antlitz zu verschaffen. ). Man darf wie bisher den "Mapbox Satellite"-Layer nutzen, aber der enthält ab jetzt Bilder von DigitalGlobe. In meinen Referenzgebieten sehe ich nun immerhin tatsächlich Bilder, wo Mapbox beim letzten V http://bleiwüsten.de/work/mapbox-interaktive-karten-erstellen/ von mobilen Geo -Web-App Slides to show to get maps on your form. Use cross-platform mapping clients to embed interactive maps in webpages and native mobile applications. Mit der mapbox Open Source Platform hat man ein Toolset und diverse REST APIs zugleich, die man schlicht zur Next Generation zählen darf. Immer mehr Apps der Geoinformationstechnologie basieren auf Basis von HTML5, CSS3 und JavaScript im Umfeld von sog. Responsive Design. Mit den modularen APIs, vor allem Static, Geocoding, Distance,Satellite und Map Matching ist man breit aufgestellt, was auch die plattformunabhängige Entwicklung fördert. Gezeigt wird mit 5 Use Cases (neudeutsch Anwendungsfälle) wie sich die 5 REST GET Calls OHNE JavaScript einbinden lassen. in einem taktfahrplan weiss fast jeder den fahrplan, wieso muss vor jedem ort noch die beschissenen durchsage kommen, und das noch in drei sprachen und mit grausigem akzent und laut, das zeug steht ja schon überall als info zur verfügung