Difference between revisions of "Contribuir para o Nominatim"

From Geomaster, Lda
Jump to navigation Jump to search
 
(14 intermediate revisions by the same user not shown)
Line 92: Line 92:
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
sudo apt-get install php-pear
+
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql php-pear php-pgsql php-intl
 
sudo pear install DB
 
sudo pear install DB
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
==== Teste do build ====
 
==== Teste do build ====
 +
 +
<syntaxhighlight lang="bash">
 +
sudo su postgres
 +
createuser --createdb --pwprompt --superuser jgr
 +
Enter password for new role: nominatim
 +
Enter it again: nominatim
 +
 +
createuser www-data
 +
exit
 +
</syntaxhighlight>
 +
 +
<syntaxhighlight lang="bash">
 +
echo "localhost:5432:*:jgr:nominatim" >> ~/.pgpass
 +
</syntaxhighlight>
 +
 +
Atenção: a importação é bastante demorada (aprox. 25 minutos para importar Portugal)
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
cd ..
 
cd ..
./build/utils/setup.php --osm-file portugal-latest.osm.pbf --all
+
wget -O data/portugal-latest.osm.pbf http://download.geofabrik.de/europe/portugal-latest.osm.pbf
 +
wget -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz
 +
./build/utils/setup.php --osm-file data/portugal-latest.osm.pbf --all
 +
</syntaxhighlight>
 +
 
 +
Depois do build, configurar o Apache para servir a partir da pasta <syntaxhighlight lang="bash" inline>build/website</syntaxhighlight>
 +
 
 +
<syntaxhighlight lang="bash">
 +
sudo vi /etc/apache2/sites-enabled/000-default.conf
 +
</syntaxhighlight>
 +
 
 +
<syntaxhighlight lang="apache2">
 +
        Alias /nominatim /home/jgr/dev/Nominatim/build/website
 +
        <Directory /home/jgr/dev/Nominatim/build/website>
 +
                Options +Indexes +FollowSymLinks
 +
                Require all granted
 +
        </Directory>
 +
</syntaxhighlight>
 +
 
 +
<syntaxhighlight lang="bash">
 +
sudo service apache2 restart
 +
</syntaxhighlight>
 +
 
 +
<syntaxhighlight lang="bash">
 +
sudo service apache2 restart
 +
</syntaxhighlight>
 +
 
 +
<syntaxhighlight lang="bash">
 +
vi /home/jgr/dev/Nominatim/build/settings/settings.php
 +
</syntaxhighlight>
 +
 
 +
<syntaxhighlight lang="bash">
 +
//@define('CONST_Website_BaseURL', 'http://'.php_uname('n').'/');
 +
@define('CONST_Website_BaseURL', 'http://'.php_uname('n').'/nominatim/');
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
Abrir: http://localhost/nominatim/search.php
 +
 +
[[File:Nominatim-sucesso.png]]
 +
 +
==== Undo ====
 +
 +
<syntaxhighlight lang="bash">
 +
sudo su postgres
 +
psql
 +
postgres=# DROP DATABASE nominatim;
 +
DROP DATABASE
 +
postgres=# DROP ROLE jgr;
 +
DROP ROLE
 +
postgres=# \q
 +
</syntaxhighlight>
 +
 +
 +
==== Queries à base de Dados nominatim ====
 +
 +
<syntaxhighlight lang="sql">
 +
SELECT l.* FROM  public.planet_osm_rels l, unnest(tags) a WHERE  lower(a) LIKE '%prefix%';
 +
SELECT l.* FROM  public.planet_osm_ways l, unnest(tags) a WHERE  lower(a) LIKE '%prefix%';
 +
select * from public.place limit 20;
 +
</syntaxhighlight>
 +
 +
==== IDE CLion ====
 +
 +
[[File:Clion new project nominatim.png]]
 +
 +
[[File:Create project from existing sources.png]]
  
 
==== Contribuições ====
 
==== Contribuições ====

Latest revision as of 00:10, 8 March 2018

Nominatim

O código fonte do projeto Nominatim está disponível no GitHub.

Antes de qualquer contribuição, deve-se ler o documento CONTRIBUTING.

Procurar issues que estejam marcados como simple:

is:open label:simple

Ciclo de vida

  1. Fork p/ a nossa conta
  2. clone localmente
  3. Criar um branch local
  4. Fazer as contribuições e testar
  5. Commit & push
  6. Fazer o Pull Request

Fork

Faz-se na interface do GitHub.

Por uma questão de nomenclatura, os repositórios para a ter os seguintes nomes:

Clone

Fazemos o clone do nosso repositório no GitHub

mkdir -p ~/dev
cd dev
git clone git@github.com:jgrocha/Nominatim.git
git clone --recursive git@github.com:jgrocha/Nominatim.git
cd Nominatim
git remote -v
origin	git@github.com:jgrocha/Nominatim.git (fetch)
origin	git@github.com:jgrocha/Nominatim.git (push)

Foi criado automaticamente a referência para o nosso repositório do GitHub com o nome origin. Falta criar um referência com o nome upstream para o repositório oficial do Nominatim.

git remote add upstream git@github.com:openstreetmap/Nominatim.git
git remote -v
origin	git@github.com:jgrocha/Nominatim.git (fetch)
origin	git@github.com:jgrocha/Nominatim.git (push)
upstream	git@github.com:openstreetmap/Nominatim.git (fetch)
upstream	git@github.com:openstreetmap/Nominatim.git (push)

Branch

git checkout -b issue823
Switched to a new branch 'issue823'

Garantir que o projeto compila direito (na linha de comandos). Corrigir dependências, se necessário.

mkdir build
cd build
cmake ..
make

Opcionalmente, deve-se abrir e usar o projeto num IDE que suporte C. CLion can be used for open source project, according to it's license.

Dependências

sudo apt install libboost-system-dev libboost-filesystem-dev python-pyosmium python3-pyosmium
sudo ln -s /usr/lib/x86_64-linux-gnu/libboost_python-py35.so.1.58.0 /usr/lib/x86_64-linux-gnu/libboost_python-py35.so
sudo ldconfig
sudo su
pip3 install osmium
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql php-pear php-pgsql php-intl
sudo pear install DB

Teste do build

sudo su postgres
createuser --createdb --pwprompt --superuser jgr
Enter password for new role: nominatim
Enter it again: nominatim

createuser www-data
exit
echo "localhost:5432:*:jgr:nominatim" >> ~/.pgpass

Atenção: a importação é bastante demorada (aprox. 25 minutos para importar Portugal)

cd ..
wget -O data/portugal-latest.osm.pbf http://download.geofabrik.de/europe/portugal-latest.osm.pbf
wget -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz
./build/utils/setup.php --osm-file data/portugal-latest.osm.pbf --all

Depois do build, configurar o Apache para servir a partir da pasta build/website

sudo vi /etc/apache2/sites-enabled/000-default.conf
        Alias /nominatim /home/jgr/dev/Nominatim/build/website
        <Directory /home/jgr/dev/Nominatim/build/website>
                Options +Indexes +FollowSymLinks
                Require all granted
        </Directory>
sudo service apache2 restart
sudo service apache2 restart
vi /home/jgr/dev/Nominatim/build/settings/settings.php
//@define('CONST_Website_BaseURL', 'http://'.php_uname('n').'/');
@define('CONST_Website_BaseURL', 'http://'.php_uname('n').'/nominatim/');

Abrir: http://localhost/nominatim/search.php

Nominatim-sucesso.png

Undo

sudo su postgres
psql 
postgres=# DROP DATABASE nominatim;
DROP DATABASE
postgres=# DROP ROLE jgr;
DROP ROLE
postgres=# \q


Queries à base de Dados nominatim

SELECT l.* FROM   public.planet_osm_rels l, unnest(tags) a WHERE  lower(a) LIKE '%prefix%';
SELECT l.* FROM   public.planet_osm_ways l, unnest(tags) a WHERE  lower(a) LIKE '%prefix%';
select * from public.place limit 20;

IDE CLion

Clion new project nominatim.png

Create project from existing sources.png

Contribuições

Commit and push

Pull request