hilbert-nunes / cities-api

API REST for world countries, cities and states of Brazil. Built with Spring Framework and PostgreSQL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cities API

deploy_heroku

Requirements

  • Linux/Windows
  • Git
  • Java 8
  • Docker
  • IntelliJ Community
  • Heroku CLI

DataBase

Postgres

docker run --name cities-db -d -p 5432:5432 -e POSTGRES_USER=postgres_user_city -e POSTGRES_PASSWORD=super_password -e POSTGRES_DB=cities postgres

Populate

cd ~/workspace/sql-paises-estados-cidades/PostgreSQL

docker run -it --rm --net=host -v $PWD:/tmp postgres /bin/bash

psql -h localhost -U postgres_user_city cities -f /tmp/pais.sql
psql -h localhost -U postgres_user_city cities -f /tmp/estado.sql
psql -h localhost -U postgres_user_city cities -f /tmp/cidade.sql

psql -h localhost -U postgres_user_city cities

CREATE EXTENSION cube; 
CREATE EXTENSION earthdistance;

Access

docker exec -it cities-db /bin/bash

psql -U postgres_user_city cities

Query Earth Distance

Point

select ((select lat_lon from cidade where id = 4929) <@> (select lat_lon from cidade where id=5254)) as distance;

Cube

select earth_distance(
    ll_to_earth(-21.95840072631836,-47.98820114135742), 
    ll_to_earth(-22.01740074157715,-47.88600158691406)
) as distance;

Spring Boot

  • Java 8
  • Gradle Project
  • Jar
  • Spring Web
  • Spring Data JPA
  • PostgreSQL Driver

Spring Data

Properties

Types

Heroku

Notes

  • Windows WSL2 was used to built it without problems
  • Read API.md

About

API REST for world countries, cities and states of Brazil. Built with Spring Framework and PostgreSQL.


Languages

Language:Java 100.0%