Difference between revisions of "OpenStreetMap API"

From Geomaster, Lda
Jump to navigation Jump to search
 
Line 27: Line 27:
 
>;
 
>;
 
out skel qt;
 
out skel qt;
 +
</syntaxhighlight>
 +
 +
=== Melhorias ===
 +
 +
Trocar:
 +
 +
<syntaxhighlight lang="text">
 +
// print results
 +
out body;
 +
>;
 +
out skel qt;
 +
</syntaxhighlight>
 +
 +
para sair o centroid, se for um polígono:
 +
 +
<syntaxhighlight lang="text">
 +
// print results
 +
out center;
 +
</syntaxhighlight>
 +
 +
Trocar:
 +
 +
<syntaxhighlight lang="text">
 +
  // query part for: “pharmacy”
 +
  node["amenity"="pharmacy"](area.searchArea);
 +
  way["amenity"="pharmacy"](area.searchArea);
 +
  relation["amenity"="pharmacy"](area.searchArea);
 +
</syntaxhighlight>
 +
 +
por:
 +
 +
<syntaxhighlight lang="text">
 +
  // query part for: “pharmacy”
 +
  nwr["amenity"="pharmacy"](area.searchArea);
 +
</syntaxhighlight>
 +
 +
 +
Resultado final:
 +
 +
<syntaxhighlight lang="text">
 +
/*
 +
This has been generated by the overpass-turbo wizard.
 +
The original search was:
 +
“pharmacy in porto”
 +
*/
 +
[out:json][timeout:25];
 +
// fetch area “porto” to search in
 +
{{geocodeArea:porto}}->.searchArea;
 +
// gather results
 +
(
 +
  // query part for: “pharmacy”
 +
  nwr["amenity"="pharmacy"](area.searchArea);
 +
);
 +
// print results
 +
out center;
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Latest revision as of 08:57, 16 May 2019

Wizard

Usar o Wizard do overpass

No Wizard escrever: 'bakery or supermarket in Braga'

No Wizard escrever: 'pharmacy in porto'

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“pharmacy in porto”
*/
[out:json][timeout:25];
// fetch area “porto” to search in
{{geocodeArea:porto}}->.searchArea;
// gather results
(
  // query part for: “pharmacy”
  node["amenity"="pharmacy"](area.searchArea);
  way["amenity"="pharmacy"](area.searchArea);
  relation["amenity"="pharmacy"](area.searchArea);
);
// print results
out body;
>;
out skel qt;

Melhorias

Trocar:

// print results
out body;
>;
out skel qt;

para sair o centroid, se for um polígono:

// print results
out center;

Trocar:

  // query part for: “pharmacy”
  node["amenity"="pharmacy"](area.searchArea);
  way["amenity"="pharmacy"](area.searchArea);
  relation["amenity"="pharmacy"](area.searchArea);

por:

  // query part for: “pharmacy”
  nwr["amenity"="pharmacy"](area.searchArea);


Resultado final:

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“pharmacy in porto”
*/
[out:json][timeout:25];
// fetch area “porto” to search in
{{geocodeArea:porto}}->.searchArea;
// gather results
(
  // query part for: “pharmacy”
  nwr["amenity"="pharmacy"](area.searchArea);
);
// print results
out center;

Manual...

Abrir http://overpass-turbo.eu/

Procurar no mapa por: Porto

Escrever a seguinte consulta:

/*
procurar por restaurantes
*/
[out:json];
// gather results
(
  node["amenity"="restaurant"]({{bbox}});
);
// print results
out body;

Executar a consulta

Restaurantes porto osm.png

Exportar e escolher descarregar como geojson

Abrir o geojson no QGIS

A codificação dos caracteres no GeoJson é UTF-8.

No QGIS, a camada é apresentada com a indicação de que se trata (e bem) do sistema de coordenadas EPSG:4326 (WGS84).

Ao passar a camada para a base de dados, indicar que pretendemos uma transformação do sistema EPSG:4326 para EPSG:3763.