-
Notifications
You must be signed in to change notification settings - Fork 567
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Kudos, SonarCloud Quality Gate passed! |
@mau0414 , pode resolver os conflitos pff? |
There was a problem hiding this 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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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
"open-location-code": "^1.0.3", | |
"open-location-code": "1.0.3", |
throw new InternalError({ | ||
status: 400, | ||
message: `Plus Code inválido`, | ||
name: 'PLUS_CODE_ERROR', | ||
type: 'PLUS_CODE_ERROR', | ||
}); | ||
} |
There was a problem hiding this comment.
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
"400": { | ||
"description": "Todos os serviços de CEP retornaram erro.", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/location" | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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
url: `https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lon}&zoom=16`, | ||
method: 'get', |
There was a problem hiding this comment.
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
There was a problem hiding this 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); |
There was a problem hiding this comment.
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
export default app().get(action); | |
export default app( { cache: 600000 } ).get(action); |
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:
Exemplo de saída:
Base do funcionamento: