Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Identificação de localização a partir de um Plus Code #554

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lucaspquadros
Copy link

Issue Relacionada

Closes #418 - Lugares sem CEP

Descrição

A partir da biblioteca "open-location-code", foi implementado uma solução que recebe como Input um Plus Code (simples código alfanumérico baseado em latitude e longitude para identificação exata de um local) e retorna, através da API Open Street Map, a rua, o bairro, a cidade, o país e o estado do local.
Para testar, basta obter um Plus Code do local desejado pelo Google Maps e verificar a saída gerada pela aplicação.

Exemplo de entrada:
entrada

Exemplo de saída:
saida

Base do funcionamento:
funcionamento

Copy link

vercel bot commented Nov 30, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
brasilapi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 30, 2023 10:26am

Copy link

sonarcloud bot commented Nov 30, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@LorhanSohaky
Copy link
Member

@mau0414 , pode resolver os conflitos pff?

Copy link
Member

@LorhanSohaky LorhanSohaky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Muito obrigado pela contribuição. Além desses detalhes, precisamos que você adicione casos de testes

@@ -11,6 +11,7 @@
"apollo-server-micro": "2.24.0",
"axios": "0.21.1",
"bluebird": "3.7.2",
"browserslist": "^4.22.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pelo que vi essa dependência não é utilizada. Poderia remover?

@@ -24,6 +25,7 @@
"next": "10.2.0",
"next-connect": "0.9.1",
"next-sitemap": "1.6.168",
"open-location-code": "^1.0.3",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aqui trabalhamos com versões pinadas, então pff mudar para o sugerido e refazer npm install

Suggested change
"open-location-code": "^1.0.3",
"open-location-code": "1.0.3",

Comment on lines +14 to +20
throw new InternalError({
status: 400,
message: `Plus Code inválido`,
name: 'PLUS_CODE_ERROR',
type: 'PLUS_CODE_ERROR',
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seria interessante diferenciar erros internos de quando o pluscode for inválido

Comment on lines +38 to +47
"400": {
"description": "Todos os serviços de CEP retornaram erro.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/location"
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Atualizar documentação com os erros corretos

Comment on lines +6 to +7
url: `https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lon}&zoom=16`,
method: 'get',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recentemente tivemos problema com essa API. Favor incluir o user-agent igual seguindo o que há na v2 da rota de cep

https://operations.osmfoundation.org/policies/nominatim/

Copy link
Collaborator

@RodriAndreotti RodriAndreotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obrigado pela contribuição!

O PR ficou muito legal, só deixei alguns comentários complementando os do @LorhanSohaky.

};


export default app().get(action);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conhecendo a api do open street maps de experiências passadas, e sabendo que essa informação não deve mudar com muita frequência eu recomendaria usar um cache mais agressivo que o padrão do projeto, assim não corremos o risco de blocks.. .rs

Suggested change
export default app().get(action);
export default app( { cache: 600000 } ).get(action);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sugestão: Lugares sem CEP
4 participants