diff --git a/config/config.exs b/config/config.exs index bc8ddeba9..28978814f 100644 --- a/config/config.exs +++ b/config/config.exs @@ -125,7 +125,8 @@ config :mobilizon, Mobilizon.Service.Geospatial.Photon, endpoint: System.get_env("GEOSPATIAL_PHOTON_ENDPOINT") || "https://photon.komoot.de" config :mobilizon, Mobilizon.Service.Geospatial.GoogleMaps, - api_key: System.get_env("GEOSPATIAL_GOOGLE_MAPS_API_KEY") || nil + api_key: System.get_env("GEOSPATIAL_GOOGLE_MAPS_API_KEY") || nil, + fetch_place_details: System.get_env("GEOSPATIAL_GOOGLE_MAPS_FETCH_PLACE_DETAILS") || true config :mobilizon, Mobilizon.Service.Geospatial.MapQuest, api_key: System.get_env("GEOSPATIAL_MAP_QUEST_API_KEY") || nil diff --git a/js/src/components/Event/AddressAutoComplete.vue b/js/src/components/Event/AddressAutoComplete.vue index b3362a61c..5dc47ea5b 100644 --- a/js/src/components/Event/AddressAutoComplete.vue +++ b/js/src/components/Event/AddressAutoComplete.vue @@ -1,53 +1,123 @@ + diff --git a/js/src/graphql/address.ts b/js/src/graphql/address.ts index 0a16a98de..3035d9ad8 100644 --- a/js/src/graphql/address.ts +++ b/js/src/graphql/address.ts @@ -5,6 +5,7 @@ export const ADDRESS = gql` searchAddress( query: $query ) { + id, description, geom, floor, @@ -12,7 +13,9 @@ export const ADDRESS = gql` locality, postalCode, region, - country + country, + url, + originId } } `; diff --git a/js/src/types/address.model.ts b/js/src/types/address.model.ts index fddab2695..b26bbfd38 100644 --- a/js/src/types/address.model.ts +++ b/js/src/types/address.model.ts @@ -1,11 +1,23 @@ export interface IAddress { - id: number; + id?: number; description: string; floor: string; street: string; locality: string; - postal_code: string; + postalCode: string; region: string; country: string; - geom: string; + geom?: string; + url?: string; + originId?: string; +} + +export class Address implements IAddress { + country: string = ''; + description: string = ''; + floor: string = ''; + locality: string = ''; + postalCode: string = ''; + region: string = ''; + street: string = ''; } diff --git a/js/src/views/Event/Create.vue b/js/src/views/Event/Create.vue index 2a0954ed7..b3c73c416 100644 --- a/js/src/views/Event/Create.vue +++ b/js/src/views/Event/Create.vue @@ -119,7 +119,6 @@ export default class CreateEvent extends Vue { createEvent(e: Event) { e.preventDefault(); - if (this.event.uuid === '') { console.log('event', this.event); this.$apollo diff --git a/js/src/views/Event/Event.vue b/js/src/views/Event/Event.vue index 7fb7f6f33..7c58f7e51 100644 --- a/js/src/views/Event/Event.vue +++ b/js/src/views/Event/Event.vue @@ -75,7 +75,7 @@
{{ event.physicalAddress.description }} {{ event.physicalAddress.floor }} {{ event.physicalAddress.street }} - {{ event.physicalAddress.postal_code }} {{ event.physicalAddress.locality }} + {{ event.physicalAddress.postalCode }} {{ event.physicalAddress.locality }}
diff --git a/js/src/views/Group/Create.vue b/js/src/views/Group/Create.vue index 26a20b7e9..8440f91ae 100644 --- a/js/src/views/Group/Create.vue +++ b/js/src/views/Group/Create.vue @@ -79,7 +79,7 @@ export default class CreateGroup extends Vue { country: addressData.country, locality: addressData.city, region: addressData.administrative_area_level_1, - postal_code: addressData.postal_code, + postalCode: addressData.postalCode, street: `${addressData.street_number} ${addressData.route}`, }; } diff --git a/lib/mobilizon/addresses/address.ex b/lib/mobilizon/addresses/address.ex index 6dfcb434a..97f635668 100644 --- a/lib/mobilizon/addresses/address.ex +++ b/lib/mobilizon/addresses/address.ex @@ -15,7 +15,8 @@ defmodule Mobilizon.Addresses.Address do :region, :postal_code, :street, - :url + :url, + :origin_id ] @required [ :url @@ -31,6 +32,7 @@ defmodule Mobilizon.Addresses.Address do field(:postal_code, :string) field(:street, :string) field(:url, :string) + field(:origin_id, :string) has_many(:event, Event, foreign_key: :physical_address_id) timestamps() diff --git a/lib/mobilizon/addresses/addresses.ex b/lib/mobilizon/addresses/addresses.ex index 0c2304f41..cc6c407c5 100644 --- a/lib/mobilizon/addresses/addresses.ex +++ b/lib/mobilizon/addresses/addresses.ex @@ -50,6 +50,8 @@ defmodule Mobilizon.Addresses do """ def get_address!(id), do: Repo.get!(Address, id) + def get_address(id), do: Repo.get(Address, id) + @doc """ Gets a single address by it's url @@ -80,7 +82,10 @@ defmodule Mobilizon.Addresses do def create_address(attrs \\ %{}) do %Address{} |> Address.changeset(attrs) - |> Repo.insert() + |> Repo.insert( + on_conflict: :replace_all_except_primary_key, + conflict_target: [:origin_id] + ) end @doc """ diff --git a/lib/mobilizon_web/resolvers/address.ex b/lib/mobilizon_web/resolvers/address.ex index 372cc03b9..cab23339b 100644 --- a/lib/mobilizon_web/resolvers/address.ex +++ b/lib/mobilizon_web/resolvers/address.ex @@ -20,6 +20,18 @@ defmodule MobilizonWeb.Resolvers.Address do addresses = Task.await(local_addresses) ++ Task.await(remote_addresses) + # If we have results with same origin_id than those locally saved, don't return them + addresses = + Enum.reduce(addresses, %{}, fn address, addresses -> + if Map.has_key?(addresses, address.origin_id) && !is_nil(address.url) do + addresses + else + Map.put(addresses, address.origin_id, address) + end + end) + + addresses = Map.values(addresses) + {:ok, addresses} end diff --git a/lib/mobilizon_web/resolvers/event.ex b/lib/mobilizon_web/resolvers/event.ex index 255a6ddc5..8a01b2cf0 100644 --- a/lib/mobilizon_web/resolvers/event.ex +++ b/lib/mobilizon_web/resolvers/event.ex @@ -208,20 +208,21 @@ defmodule MobilizonWeb.Resolvers.Event do defp save_attached_picture(args), do: {:ok, args} @spec save_physical_address(map()) :: {:ok, map()} - defp save_physical_address(%{physical_address: %{url: physical_address_url}} = args) do + defp save_physical_address(%{physical_address: %{url: physical_address_url}} = args) + when not is_nil(physical_address_url) do with %Address{} = address <- Addresses.get_address_by_url(physical_address_url), - args <- Map.put(args, :physical_address, address) do + args <- Map.put(args, :physical_address, address.url) do {:ok, args} end end - # @spec save_physical_address(map()) :: {:ok, map()} - # defp save_physical_address(%{physical_address: address} = args) do - # with {:ok, %Address{} = address} <- Addresses.create_address(address), - # args <- Map.put(args, :physical_address, address) do - # {:ok, args} - # end - # end + @spec save_physical_address(map()) :: {:ok, map()} + defp save_physical_address(%{physical_address: address} = args) do + with {:ok, %Address{} = address} <- Addresses.create_address(address), + args <- Map.put(args, :physical_address, address.url) do + {:ok, args} + end + end @spec save_physical_address(map()) :: {:ok, map()} defp save_physical_address(args), do: {:ok, args} diff --git a/lib/mobilizon_web/schema/address.ex b/lib/mobilizon_web/schema/address.ex index 2bbbb0bec..71f69a951 100644 --- a/lib/mobilizon_web/schema/address.ex +++ b/lib/mobilizon_web/schema/address.ex @@ -15,6 +15,8 @@ defmodule MobilizonWeb.Schema.AddressType do field(:country, :string) field(:description, :string) field(:url, :string) + field(:id, :integer) + field(:origin_id, :string) end object :phone_address do @@ -38,6 +40,8 @@ defmodule MobilizonWeb.Schema.AddressType do field(:country, :string) field(:description, :string) field(:url, :string) + field(:id, :integer) + field(:origin_id, :string) end object :address_queries do diff --git a/lib/service/activity_pub/converters/event.ex b/lib/service/activity_pub/converters/event.ex index 0b069f90b..c832defca 100644 --- a/lib/service/activity_pub/converters/event.ex +++ b/lib/service/activity_pub/converters/event.ex @@ -69,6 +69,10 @@ defmodule Mobilizon.Service.ActivityPub.Converters.Event do end end + defp get_address(address_url) when is_bitstring(address_url) do + get_address(%{"id" => address_url}) + end + defp get_address(%{"id" => url} = map) when is_map(map) and is_binary(url) do Logger.debug("Address with an URL, let's check against our own database") diff --git a/lib/service/activity_pub/utils.ex b/lib/service/activity_pub/utils.ex index a47f38a97..a76539549 100644 --- a/lib/service/activity_pub/utils.ex +++ b/lib/service/activity_pub/utils.ex @@ -11,6 +11,7 @@ defmodule Mobilizon.Service.ActivityPub.Utils do """ alias Mobilizon.Repo + alias Mobilizon.Addresses alias Mobilizon.Addresses.Address alias Mobilizon.Actors alias Mobilizon.Actors.Actor @@ -301,37 +302,44 @@ defmodule Mobilizon.Service.ActivityPub.Utils do end def make_address_data(%Address{} = address) do - res = %{ - "type" => "Place", - "name" => address.description, - "id" => address.url, - "address" => %{ - "type" => "PostalAddress", - "streetAddress" => address.street, - "postalCode" => address.postal_code, - "addressLocality" => address.locality, - "addressRegion" => address.region, - "addressCountry" => address.country - } - } - - if is_nil(address.geom) do - res - else - Map.put(res, "geo", %{ - "type" => "GeoCoordinates", - "latitude" => address.geom.coordinates |> elem(0), - "longitude" => address.geom.coordinates |> elem(1) - }) - end + # res = %{ + # "type" => "Place", + # "name" => address.description, + # "id" => address.url, + # "address" => %{ + # "type" => "PostalAddress", + # "streetAddress" => address.street, + # "postalCode" => address.postal_code, + # "addressLocality" => address.locality, + # "addressRegion" => address.region, + # "addressCountry" => address.country + # } + # } + # + # if is_nil(address.geom) do + # res + # else + # Map.put(res, "geo", %{ + # "type" => "GeoCoordinates", + # "latitude" => address.geom.coordinates |> elem(0), + # "longitude" => address.geom.coordinates |> elem(1) + # }) + # end + address.url end - def make_address_data(address) do + def make_address_data(address) when is_map(address) do Address |> struct(address) |> make_address_data() end + def make_address_data(address_url) when is_bitstring(address_url) do + with %Address{} = address <- Addresses.get_address_by_url(address_url) do + address.url + end + end + @doc """ Make an AP comment object from an set of values """ diff --git a/lib/service/geospatial/google_maps.ex b/lib/service/geospatial/google_maps.ex index 1d5f8b2f8..7b73475f7 100644 --- a/lib/service/geospatial/google_maps.ex +++ b/lib/service/geospatial/google_maps.ex @@ -12,6 +12,9 @@ defmodule Mobilizon.Service.Geospatial.GoogleMaps do @api_key Application.get_env(:mobilizon, __MODULE__) |> get_in([:api_key]) + @fetch_place_details (Application.get_env(:mobilizon, __MODULE__) + |> get_in([:fetch_place_details])) in [true, "true", "True"] + @components [ "street_number", "route", @@ -36,7 +39,7 @@ defmodule Mobilizon.Service.Geospatial.GoogleMaps do with {:ok, %HTTPoison.Response{status_code: 200, body: body}} <- HTTPoison.get(url), {:ok, %{"results" => results, "status" => "OK"}} <- Poison.decode(body) do - Enum.map(results, &process_data/1) + Enum.map(results, fn entry -> process_data(entry, options) end) else {:ok, %{"status" => "REQUEST_DENIED", "error_message" => error_message}} -> raise ArgumentError, message: to_string(error_message) @@ -56,10 +59,13 @@ defmodule Mobilizon.Service.Geospatial.GoogleMaps do with {:ok, %HTTPoison.Response{status_code: 200, body: body}} <- HTTPoison.get(url), {:ok, %{"results" => results, "status" => "OK"}} <- Poison.decode(body) do - Enum.map(results, fn entry -> process_data(entry) end) + results |> Enum.map(fn entry -> process_data(entry, options) end) else {:ok, %{"status" => "REQUEST_DENIED", "error_message" => error_message}} -> raise ArgumentError, message: to_string(error_message) + + {:ok, %{"results" => [], "status" => "ZERO_RESULTS"}} -> + [] end end @@ -75,26 +81,45 @@ defmodule Mobilizon.Service.Geospatial.GoogleMaps do lang }" - case method do - :search -> - url <> "&address=#{URI.encode(args.q)}" + uri = + case method do + :search -> + url <> "&address=#{args.q}" - :geocode -> - url <> "&latlng=#{args.lat},#{args.lon}" - end + :geocode -> + url <> "&latlng=#{args.lat},#{args.lon}&result_type=street_address" + + :place_details -> + "https://maps.googleapis.com/maps/api/place/details/json?key=#{api_key}&placeid=#{ + args.place_id + }" + end + + URI.encode(uri) end - defp process_data(%{ - "formatted_address" => description, - "geometry" => %{"location" => %{"lat" => lat, "lng" => lon}}, - "address_components" => components - }) do + defp process_data( + %{ + "formatted_address" => description, + "geometry" => %{"location" => %{"lat" => lat, "lng" => lon}}, + "address_components" => components, + "place_id" => place_id + }, + options + ) do components = @components |> Enum.reduce(%{}, fn component, acc -> Map.put(acc, component, extract_component(components, component)) end) + description = + if Keyword.get(options, :fetch_place_details, @fetch_place_details) == true do + do_fetch_place_details(place_id, options) || description + else + description + end + %Address{ country: Map.get(components, "country"), locality: Map.get(components, "locality"), @@ -103,7 +128,8 @@ defmodule Mobilizon.Service.Geospatial.GoogleMaps do floor: nil, geom: [lon, lat] |> Provider.coordinates(), postal_code: Map.get(components, "postal_code"), - street: street_address(components) + street: street_address(components), + origin_id: "gm:" <> to_string(place_id) } end @@ -123,4 +149,25 @@ defmodule Mobilizon.Service.Geospatial.GoogleMaps do Map.get(body, "route") end end + + defp do_fetch_place_details(place_id, options) do + url = build_url(:place_details, %{place_id: place_id}, options) + + Logger.debug("Asking Google Maps for details with #{url}") + + with {:ok, %HTTPoison.Response{status_code: 200, body: body}} <- + HTTPoison.get(url), + {:ok, %{"result" => %{"name" => name}, "status" => "OK"}} <- Poison.decode(body) do + name + else + {:ok, %{"status" => "REQUEST_DENIED", "error_message" => error_message}} -> + raise ArgumentError, message: to_string(error_message) + + {:ok, %{"status" => "INVALID_REQUEST"}} -> + raise ArgumentError, message: "Invalid Request" + + {:ok, %{"results" => [], "status" => "ZERO_RESULTS"}} -> + nil + end + end end diff --git a/lib/service/geospatial/nominatim.ex b/lib/service/geospatial/nominatim.ex index a4ac719c6..029bed62e 100644 --- a/lib/service/geospatial/nominatim.ex +++ b/lib/service/geospatial/nominatim.ex @@ -39,7 +39,7 @@ defmodule Mobilizon.Service.Geospatial.Nominatim do with {:ok, %HTTPoison.Response{status_code: 200, body: body}} <- HTTPoison.get(url), {:ok, body} <- Poison.decode(body) do - Enum.map(body, fn entry -> process_data(entry) end) + body |> Enum.map(fn entry -> process_data(entry) end) |> Enum.filter(& &1) end end @@ -66,24 +66,63 @@ defmodule Mobilizon.Service.Geospatial.Nominatim do @spec process_data(map()) :: Address.t() defp process_data(%{"address" => address} = body) do - %Address{ - country: Map.get(address, "country"), - locality: Map.get(address, "city"), - region: Map.get(address, "state"), - description: Map.get(body, "display_name"), - floor: Map.get(address, "floor"), - geom: [Map.get(body, "lon"), Map.get(body, "lat")] |> Provider.coordinates(), - postal_code: Map.get(address, "postcode"), - street: street_address(address) - } + try do + %Address{ + country: Map.get(address, "country"), + locality: Map.get(address, "city"), + region: Map.get(address, "state"), + description: description(body), + floor: Map.get(address, "floor"), + geom: [Map.get(body, "lon"), Map.get(body, "lat")] |> Provider.coordinates(), + postal_code: Map.get(address, "postcode"), + street: street_address(address), + origin_id: "osm:" <> to_string(Map.get(body, "osm_id")) + } + rescue + e in ArgumentError -> + Logger.warn(inspect(e)) + nil + end end @spec street_address(map()) :: String.t() defp street_address(body) do - if Map.has_key?(body, "house_number") do - Map.get(body, "house_number") <> " " <> Map.get(body, "road") + road = + cond do + Map.has_key?(body, "road") -> + Map.get(body, "road") + + Map.has_key?(body, "road") -> + Map.get(body, "road") + + Map.has_key?(body, "pedestrian") -> + Map.get(body, "pedestrian") + + true -> + "" + end + + Map.get(body, "house_number", "") <> " " <> road + end + + @address29_classes ["amenity", "shop", "tourism", "leisure"] + @address29_categories ["office"] + + @spec description(map()) :: String.t() + defp description(body) do + if !Map.has_key?(body, "display_name") do + Logger.warn("Address has no display name") + raise ArgumentError, message: "Address has no display_name" + end + + description = Map.get(body, "display_name") + address = Map.get(body, "address") + + if (Map.get(body, "category") in @address29_categories or + Map.get(body, "class") in @address29_classes) and Map.has_key?(address, "address29") do + Map.get(address, "address29") else - Map.get(body, "road") + description end end end diff --git a/priv/repo/migrations/20190821161658_add_origin_id_to_addresses.exs b/priv/repo/migrations/20190821161658_add_origin_id_to_addresses.exs new file mode 100644 index 000000000..3bf2e0712 --- /dev/null +++ b/priv/repo/migrations/20190821161658_add_origin_id_to_addresses.exs @@ -0,0 +1,11 @@ +defmodule Mobilizon.Repo.Migrations.AddOriginIdToAddresses do + use Ecto.Migration + + def change do + alter table(:addresses) do + add(:origin_id, :string) + end + + create(index(:addresses, [:origin_id], unique: true)) + end +end diff --git a/schema.graphql b/schema.graphql index dcd56724a..e620739a8 100644 --- a/schema.graphql +++ b/schema.graphql @@ -1,5 +1,5 @@ # source: http://localhost:4000/api -# timestamp: Wed Aug 21 2019 09:02:13 GMT+0200 (GMT+02:00) +# timestamp: Thu Aug 22 2019 12:34:52 GMT+0200 (GMT+02:00) schema { query: RootQueryType @@ -111,9 +111,11 @@ type Address { """The geocoordinates for the point where this address is""" geom: Point + id: Int """The address's locality""" locality: String + originId: String postalCode: String region: String @@ -131,9 +133,11 @@ input AddressInput { """The geocoordinates for the point where this address is""" geom: Point + id: Int """The address's locality""" locality: String + originId: String postalCode: String region: String diff --git a/test/fixtures/vcr_cassettes/geospatial/google_maps/geocode.json b/test/fixtures/vcr_cassettes/geospatial/google_maps/geocode.json index edfaacc02..26bbccc47 100644 --- a/test/fixtures/vcr_cassettes/geospatial/google_maps/geocode.json +++ b/test/fixtures/vcr_cassettes/geospatial/google_maps/geocode.json @@ -6,22 +6,52 @@ "method": "get", "options": [], "request_body": "", - "url": "https://maps.googleapis.com/maps/api/geocode/json?latlng=45.751718,4.842569&key=toto&language=en" + "url": "https://maps.googleapis.com/maps/api/place/details/json?key=toto&placeid=ChIJrW0QikTq9EcR96jk2OnO75w" }, "response": { "binary": false, - "body": "{\n \"plus_code\" : {\n \"compound_code\" : \"QR2V+M2 Lyon, France\",\n \"global_code\" : \"8FQ6QR2V+M2\"\n },\n \"results\" : [\n {\n \"address_components\" : [\n {\n \"long_name\" : \"10\",\n \"short_name\" : \"10\",\n \"types\" : [ \"street_number\" ]\n },\n {\n \"long_name\" : \"Rue Jangot\",\n \"short_name\" : \"Rue Jangot\",\n \"types\" : [ \"route\" ]\n },\n {\n \"long_name\" : \"Lyon\",\n \"short_name\" : \"Lyon\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Rhône\",\n \"short_name\" : \"Rhône\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n },\n {\n \"long_name\" : \"69007\",\n \"short_name\" : \"69007\",\n \"types\" : [ \"postal_code\" ]\n }\n ],\n \"formatted_address\" : \"10 Rue Jangot, 69007 Lyon, France\",\n \"geometry\" : {\n \"location\" : {\n \"lat\" : 45.751725,\n \"lng\" : 4.8424967\n },\n \"location_type\" : \"ROOFTOP\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 45.7530739802915,\n \"lng\" : 4.843845680291502\n },\n \"southwest\" : {\n \"lat\" : 45.7503760197085,\n \"lng\" : 4.841147719708498\n }\n }\n },\n \"place_id\" : \"ChIJrW0QikTq9EcRy4OdnHY6uS4\",\n \"plus_code\" : {\n \"compound_code\" : \"QR2R+MX Lyon, France\",\n \"global_code\" : \"8FQ6QR2R+MX\"\n },\n \"types\" : [ \"establishment\", \"point_of_interest\" ]\n },\n {\n \"address_components\" : [\n {\n \"long_name\" : \"10bis\",\n \"short_name\" : \"10bis\",\n \"types\" : [ \"street_number\" ]\n },\n {\n \"long_name\" : \"Rue Jangot\",\n \"short_name\" : \"Rue Jangot\",\n \"types\" : [ \"route\" ]\n },\n {\n \"long_name\" : \"Lyon\",\n \"short_name\" : \"Lyon\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Rhône\",\n \"short_name\" : \"Rhône\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n },\n {\n \"long_name\" : \"69007\",\n \"short_name\" : \"69007\",\n \"types\" : [ \"postal_code\" ]\n }\n ],\n \"formatted_address\" : \"10bis Rue Jangot, 69007 Lyon, France\",\n \"geometry\" : {\n \"location\" : {\n \"lat\" : 45.751725,\n \"lng\" : 4.8424966\n },\n \"location_type\" : \"ROOFTOP\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 45.7530739802915,\n \"lng\" : 4.843845580291503\n },\n \"southwest\" : {\n \"lat\" : 45.7503760197085,\n \"lng\" : 4.841147619708499\n }\n }\n },\n \"place_id\" : \"ChIJrW0QikTq9EcR96jk2OnO75w\",\n \"plus_code\" : {\n \"compound_code\" : \"QR2R+MX Lyon, France\",\n \"global_code\" : \"8FQ6QR2R+MX\"\n },\n \"types\" : [ \"street_address\" ]\n },\n {\n \"address_components\" : [\n {\n \"long_name\" : \"9\",\n \"short_name\" : \"9\",\n \"types\" : [ \"street_number\" ]\n },\n {\n \"long_name\" : \"Rue Jangot\",\n \"short_name\" : \"Rue Jangot\",\n \"types\" : [ \"route\" ]\n },\n {\n \"long_name\" : \"Lyon\",\n \"short_name\" : \"Lyon\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Rhône\",\n \"short_name\" : \"Rhône\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n },\n {\n \"long_name\" : \"69007\",\n \"short_name\" : \"69007\",\n \"types\" : [ \"postal_code\" ]\n }\n ],\n \"formatted_address\" : \"9 Rue Jangot, 69007 Lyon, France\",\n \"geometry\" : {\n \"location\" : {\n \"lat\" : 45.7518165,\n \"lng\" : 4.8427168\n },\n \"location_type\" : \"RANGE_INTERPOLATED\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 45.7531654802915,\n \"lng\" : 4.844065780291502\n },\n \"southwest\" : {\n \"lat\" : 45.7504675197085,\n \"lng\" : 4.841367819708497\n }\n }\n },\n \"place_id\" : \"EiA5IFJ1ZSBKYW5nb3QsIDY5MDA3IEx5b24sIEZyYW5jZSIaEhgKFAoSCR8N2ItE6vRHEW9tyPnhQsUIEAk\",\n \"types\" : [ \"street_address\" ]\n },\n {\n \"address_components\" : [\n {\n \"long_name\" : \"10\",\n \"short_name\" : \"10\",\n \"types\" : [ \"street_number\" ]\n },\n {\n \"long_name\" : \"Rue Jangot\",\n \"short_name\" : \"Rue Jangot\",\n \"types\" : [ \"route\" ]\n },\n {\n \"long_name\" : \"Lyon\",\n \"short_name\" : \"Lyon\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Rhône\",\n \"short_name\" : \"Rhône\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n },\n {\n \"long_name\" : \"69007\",\n \"short_name\" : \"69007\",\n \"types\" : [ \"postal_code\" ]\n }\n ],\n \"formatted_address\" : \"10 Rue Jangot, 69007 Lyon, France\",\n \"geometry\" : {\n \"bounds\" : {\n \"northeast\" : {\n \"lat\" : 45.7518154,\n \"lng\" : 4.8427199\n },\n \"southwest\" : {\n \"lat\" : 45.75173520000001,\n \"lng\" : 4.8422361\n }\n },\n \"location\" : {\n \"lat\" : 45.7517676,\n \"lng\" : 4.8424811\n },\n \"location_type\" : \"GEOMETRIC_CENTER\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 45.7531242802915,\n \"lng\" : 4.843826980291502\n },\n \"southwest\" : {\n \"lat\" : 45.75042631970851,\n \"lng\" : 4.841129019708498\n }\n }\n },\n \"place_id\" : \"ChIJadQ-ikTq9EcRo9mAXlItDZw\",\n \"types\" : [ \"route\" ]\n },\n {\n \"address_components\" : [\n {\n \"long_name\" : \"Saint Michel - Mairie\",\n \"short_name\" : \"St Michel - Mairie\",\n \"types\" : [ \"neighborhood\", \"political\" ]\n },\n {\n \"long_name\" : \"Lyon\",\n \"short_name\" : \"Lyon\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Rhône\",\n \"short_name\" : \"Rhône\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n },\n {\n \"long_name\" : \"69007\",\n \"short_name\" : \"69007\",\n \"types\" : [ \"postal_code\" ]\n }\n ],\n \"formatted_address\" : \"St Michel - Mairie, 69007 Lyon, France\",\n \"geometry\" : {\n \"bounds\" : {\n \"northeast\" : {\n \"lat\" : 45.755675,\n \"lng\" : 4.846115999999999\n },\n \"southwest\" : {\n \"lat\" : 45.7458619,\n \"lng\" : 4.8380151\n }\n },\n \"location\" : {\n \"lat\" : 45.7481588,\n \"lng\" : 4.841602099999999\n },\n \"location_type\" : \"APPROXIMATE\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 45.755675,\n \"lng\" : 4.846115999999999\n },\n \"southwest\" : {\n \"lat\" : 45.7458619,\n \"lng\" : 4.8380151\n }\n }\n },\n \"place_id\" : \"ChIJ0zUnFUTq9EcRfrgAlAvv5ps\",\n \"types\" : [ \"neighborhood\", \"political\" ]\n },\n {\n \"address_components\" : [\n {\n \"long_name\" : \"7th arrondissement of Lyon\",\n \"short_name\" : \"7th arrondissement of Lyon\",\n \"types\" : [ \"political\", \"sublocality\", \"sublocality_level_1\" ]\n },\n {\n \"long_name\" : \"Lyon\",\n \"short_name\" : \"Lyon\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Rhône\",\n \"short_name\" : \"Rhône\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n },\n {\n \"long_name\" : \"69007\",\n \"short_name\" : \"69007\",\n \"types\" : [ \"postal_code\" ]\n }\n ],\n \"formatted_address\" : \"7th arrondissement of Lyon, 69007 Lyon, France\",\n \"geometry\" : {\n \"bounds\" : {\n \"northeast\" : {\n \"lat\" : 45.756743,\n \"lng\" : 4.8599059\n },\n \"southwest\" : {\n \"lat\" : 45.707486,\n \"lng\" : 4.8187161\n }\n },\n \"location\" : {\n \"lat\" : 45.7304251,\n \"lng\" : 4.8399378\n },\n \"location_type\" : \"APPROXIMATE\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 45.756743,\n \"lng\" : 4.8599059\n },\n \"southwest\" : {\n \"lat\" : 45.707486,\n \"lng\" : 4.8187161\n }\n }\n },\n \"place_id\" : \"ChIJ-_L7biTq9EcRIBnC5CqrCAU\",\n \"types\" : [ \"political\", \"sublocality\", \"sublocality_level_1\" ]\n },\n {\n \"address_components\" : [\n {\n \"long_name\" : \"69007\",\n \"short_name\" : \"69007\",\n \"types\" : [ \"postal_code\" ]\n },\n {\n \"long_name\" : \"Lyon\",\n \"short_name\" : \"Lyon\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Rhône\",\n \"short_name\" : \"Rhône\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n }\n ],\n \"formatted_address\" : \"69007 Lyon, France\",\n \"geometry\" : {\n \"bounds\" : {\n \"northeast\" : {\n \"lat\" : 45.7567599,\n \"lng\" : 4.8599819\n },\n \"southwest\" : {\n \"lat\" : 45.7073626,\n \"lng\" : 4.8187218\n }\n },\n \"location\" : {\n \"lat\" : 45.7304251,\n \"lng\" : 4.8399378\n },\n \"location_type\" : \"APPROXIMATE\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 45.7567599,\n \"lng\" : 4.8599819\n },\n \"southwest\" : {\n \"lat\" : 45.7073626,\n \"lng\" : 4.8187218\n }\n }\n },\n \"place_id\" : \"ChIJ-_L7biTq9EcRcHzkQS6rCBw\",\n \"types\" : [ \"postal_code\" ]\n },\n {\n \"address_components\" : [\n {\n \"long_name\" : \"Lyon\",\n \"short_name\" : \"Lyon\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Rhône\",\n \"short_name\" : \"Rhône\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n }\n ],\n \"formatted_address\" : \"Lyon, France\",\n \"geometry\" : {\n \"bounds\" : {\n \"northeast\" : {\n \"lat\" : 45.808425,\n \"lng\" : 4.898393\n },\n \"southwest\" : {\n \"lat\" : 45.707486,\n \"lng\" : 4.7718489\n }\n },\n \"location\" : {\n \"lat\" : 45.764043,\n \"lng\" : 4.835659\n },\n \"location_type\" : \"APPROXIMATE\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 45.808425,\n \"lng\" : 4.898393\n },\n \"southwest\" : {\n \"lat\" : 45.707486,\n \"lng\" : 4.7718489\n }\n }\n },\n \"place_id\" : \"ChIJl4foalHq9EcR8CG75CqrCAQ\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"address_components\" : [\n {\n \"long_name\" : \"Rhône\",\n \"short_name\" : \"Rhône\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n }\n ],\n \"formatted_address\" : \"Rhône, France\",\n \"geometry\" : {\n \"bounds\" : {\n \"northeast\" : {\n \"lat\" : 46.30650199999999,\n \"lng\" : 5.1601089\n },\n \"southwest\" : {\n \"lat\" : 45.45413,\n \"lng\" : 4.243647\n }\n },\n \"location\" : {\n \"lat\" : 45.7351456,\n \"lng\" : 4.6108043\n },\n \"location_type\" : \"APPROXIMATE\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 46.30650199999999,\n \"lng\" : 5.1601089\n },\n \"southwest\" : {\n \"lat\" : 45.45413,\n \"lng\" : 4.243647\n }\n }\n },\n \"place_id\" : \"ChIJcf_obOGN9EcR0Cm55CqrCAM\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"address_components\" : [\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n }\n ],\n \"formatted_address\" : \"Auvergne-Rhône-Alpes, France\",\n \"geometry\" : {\n \"bounds\" : {\n \"northeast\" : {\n \"lat\" : 46.804293,\n \"lng\" : 7.1855661\n },\n \"southwest\" : {\n \"lat\" : 44.115493,\n \"lng\" : 2.062882\n }\n },\n \"location\" : {\n \"lat\" : 45.4471431,\n \"lng\" : 4.385250699999999\n },\n \"location_type\" : \"APPROXIMATE\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 46.804293,\n \"lng\" : 7.1855661\n },\n \"southwest\" : {\n \"lat\" : 44.115493,\n \"lng\" : 2.062882\n }\n }\n },\n \"place_id\" : \"ChIJ_fju9ukE9UcROuOAIn5wRjk\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"address_components\" : [\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n }\n ],\n \"formatted_address\" : \"France\",\n \"geometry\" : {\n \"bounds\" : {\n \"northeast\" : {\n \"lat\" : 51.1241999,\n \"lng\" : 9.6624999\n },\n \"southwest\" : {\n \"lat\" : 41.31433,\n \"lng\" : -5.5591\n }\n },\n \"location\" : {\n \"lat\" : 46.227638,\n \"lng\" : 2.213749\n },\n \"location_type\" : \"APPROXIMATE\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 51.1241999,\n \"lng\" : 9.6624999\n },\n \"southwest\" : {\n \"lat\" : 41.31433,\n \"lng\" : -5.5591\n }\n }\n },\n \"place_id\" : \"ChIJMVd4MymgVA0R99lHx5Y__Ws\",\n \"types\" : [ \"country\", \"political\" ]\n }\n ],\n \"status\" : \"OK\"\n}\n", + "body": "{\n \"html_attributions\" : [],\n \"result\" : {\n \"address_components\" : [\n {\n \"long_name\" : \"10bis\",\n \"short_name\" : \"10bis\",\n \"types\" : [ \"street_number\" ]\n },\n {\n \"long_name\" : \"Rue Jangot\",\n \"short_name\" : \"Rue Jangot\",\n \"types\" : [ \"route\" ]\n },\n {\n \"long_name\" : \"Lyon\",\n \"short_name\" : \"Lyon\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Rhône\",\n \"short_name\" : \"Rhône\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n },\n {\n \"long_name\" : \"69007\",\n \"short_name\" : \"69007\",\n \"types\" : [ \"postal_code\" ]\n }\n ],\n \"adr_address\" : \"\\u003cspan class=\\\"street-address\\\"\\u003e10bis Rue Jangot\\u003c/span\\u003e, \\u003cspan class=\\\"postal-code\\\"\\u003e69007\\u003c/span\\u003e \\u003cspan class=\\\"locality\\\"\\u003eLyon\\u003c/span\\u003e, \\u003cspan class=\\\"country-name\\\"\\u003eFrance\\u003c/span\\u003e\",\n \"formatted_address\" : \"10bis Rue Jangot, 69007 Lyon, France\",\n \"geometry\" : {\n \"location\" : {\n \"lat\" : 45.751725,\n \"lng\" : 4.8424966\n },\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 45.7531097802915,\n \"lng\" : 4.843951380291502\n },\n \"southwest\" : {\n \"lat\" : 45.7504118197085,\n \"lng\" : 4.841253419708497\n }\n }\n },\n \"icon\" : \"https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png\",\n \"id\" : \"4a3482a7a74c6203048adf713b736186c4ace7cd\",\n \"name\" : \"10bis Rue Jangot\",\n \"place_id\" : \"ChIJrW0QikTq9EcR96jk2OnO75w\",\n \"plus_code\" : {\n \"compound_code\" : \"QR2R+MX Lyon, France\",\n \"global_code\" : \"8FQ6QR2R+MX\"\n },\n \"reference\" : \"ChIJrW0QikTq9EcR96jk2OnO75w\",\n \"scope\" : \"GOOGLE\",\n \"types\" : [ \"street_address\" ],\n \"url\" : \"https://maps.google.com/?q=10bis+Rue+Jangot,+69007+Lyon,+France&ftid=0x47f4ea448a106dad:0x9cefcee9d8e4a8f7\",\n \"utc_offset\" : 120,\n \"vicinity\" : \"Lyon\"\n },\n \"status\" : \"OK\"\n}\n", "headers": { "Content-Type": "application/json; charset=UTF-8", - "Date": "Wed, 13 Mar 2019 17:53:53 GMT", - "Expires": "Thu, 14 Mar 2019 17:53:53 GMT", - "Cache-Control": "public, max-age=86400", + "Date": "Thu, 22 Aug 2019 13:18:50 GMT", + "Expires": "Thu, 22 Aug 2019 13:23:50 GMT", + "Cache-Control": "public, max-age=300", + "Server": "scaffolding on HTTPServer2", + "X-XSS-Protection": "0", + "X-Frame-Options": "SAMEORIGIN", + "Server-Timing": "gfet4t7; dur=87", + "Alt-Svc": "quic=\":443\"; ma=2592000; v=\"46,43,39\"", + "Accept-Ranges": "none", + "Vary": "Accept-Language,Accept-Encoding", + "Transfer-Encoding": "chunked" + }, + "status_code": 200, + "type": "ok" + } + }, + { + "request": { + "body": "", + "headers": [], + "method": "get", + "options": [], + "request_body": "", + "url": "https://maps.googleapis.com/maps/api/geocode/json?limit=10&key=toto&language=en&latlng=45.751718,4.842569&result_type=street_address" + }, + "response": { + "binary": false, + "body": "{\n \"plus_code\" : {\n \"compound_code\" : \"QR2V+M2 Lyon, France\",\n \"global_code\" : \"8FQ6QR2V+M2\"\n },\n \"results\" : [\n {\n \"address_components\" : [\n {\n \"long_name\" : \"10bis\",\n \"short_name\" : \"10bis\",\n \"types\" : [ \"street_number\" ]\n },\n {\n \"long_name\" : \"Rue Jangot\",\n \"short_name\" : \"Rue Jangot\",\n \"types\" : [ \"route\" ]\n },\n {\n \"long_name\" : \"Lyon\",\n \"short_name\" : \"Lyon\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Rhône\",\n \"short_name\" : \"Rhône\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n },\n {\n \"long_name\" : \"69007\",\n \"short_name\" : \"69007\",\n \"types\" : [ \"postal_code\" ]\n }\n ],\n \"formatted_address\" : \"10bis Rue Jangot, 69007 Lyon, France\",\n \"geometry\" : {\n \"location\" : {\n \"lat\" : 45.751725,\n \"lng\" : 4.8424966\n },\n \"location_type\" : \"ROOFTOP\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 45.7530739802915,\n \"lng\" : 4.843845580291503\n },\n \"southwest\" : {\n \"lat\" : 45.7503760197085,\n \"lng\" : 4.841147619708499\n }\n }\n },\n \"place_id\" : \"ChIJrW0QikTq9EcR96jk2OnO75w\",\n \"plus_code\" : {\n \"compound_code\" : \"QR2R+MX Lyon, France\",\n \"global_code\" : \"8FQ6QR2R+MX\"\n },\n \"types\" : [ \"street_address\" ]\n },\n {\n \"address_components\" : [\n {\n \"long_name\" : \"9\",\n \"short_name\" : \"9\",\n \"types\" : [ \"street_number\" ]\n },\n {\n \"long_name\" : \"Rue Jangot\",\n \"short_name\" : \"Rue Jangot\",\n \"types\" : [ \"route\" ]\n },\n {\n \"long_name\" : \"Lyon\",\n \"short_name\" : \"Lyon\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Rhône\",\n \"short_name\" : \"Rhône\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n },\n {\n \"long_name\" : \"69007\",\n \"short_name\" : \"69007\",\n \"types\" : [ \"postal_code\" ]\n }\n ],\n \"formatted_address\" : \"9 Rue Jangot, 69007 Lyon, France\",\n \"geometry\" : {\n \"location\" : {\n \"lat\" : 45.7518165,\n \"lng\" : 4.8427168\n },\n \"location_type\" : \"RANGE_INTERPOLATED\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 45.7531654802915,\n \"lng\" : 4.844065780291502\n },\n \"southwest\" : {\n \"lat\" : 45.7504675197085,\n \"lng\" : 4.841367819708497\n }\n }\n },\n \"place_id\" : \"EiA5IFJ1ZSBKYW5nb3QsIDY5MDA3IEx5b24sIEZyYW5jZSIaEhgKFAoSCR8N2ItE6vRHEW9tyPnhQsUIEAk\",\n \"types\" : [ \"street_address\" ]\n }\n ],\n \"status\" : \"OK\"\n}\n", + "headers": { + "Content-Type": "application/json; charset=UTF-8", + "Date": "Thu, 22 Aug 2019 13:18:50 GMT", + "Expires": "Thu, 22 Aug 2019 13:19:20 GMT", + "Cache-Control": "public, max-age=30", "Access-Control-Allow-Origin": "*", "Server": "mafe", - "X-XSS-Protection": "1; mode=block", + "X-XSS-Protection": "0", "X-Frame-Options": "SAMEORIGIN", - "Server-Timing": "gfet4t7; dur=44", - "Alt-Svc": "quic=\":443\"; ma=2592000; v=\"46,44,43,39\"", + "Server-Timing": "gfet4t7; dur=30", + "Alt-Svc": "quic=\":443\"; ma=2592000; v=\"46,43,39\"", "Accept-Ranges": "none", "Vary": "Accept-Encoding", "Transfer-Encoding": "chunked" @@ -30,4 +60,4 @@ "type": "ok" } } -] +] \ No newline at end of file diff --git a/test/fixtures/vcr_cassettes/geospatial/google_maps/search.json b/test/fixtures/vcr_cassettes/geospatial/google_maps/search.json index 9963a55cf..f06de36bc 100644 --- a/test/fixtures/vcr_cassettes/geospatial/google_maps/search.json +++ b/test/fixtures/vcr_cassettes/geospatial/google_maps/search.json @@ -6,23 +6,22 @@ "method": "get", "options": [], "request_body": "", - "url": "https://maps.googleapis.com/maps/api/geocode/json?address=10%20rue%20Jangot&limit=10&key=toto&language=en" + "url": "https://maps.googleapis.com/maps/api/geocode/json?limit=10&key=toto&language=en&address=10%20rue%20Jangot" }, "response": { "binary": false, "body": "{\n \"results\" : [\n {\n \"address_components\" : [\n {\n \"long_name\" : \"10\",\n \"short_name\" : \"10\",\n \"types\" : [ \"street_number\" ]\n },\n {\n \"long_name\" : \"Rue Jangot\",\n \"short_name\" : \"Rue Jangot\",\n \"types\" : [ \"route\" ]\n },\n {\n \"long_name\" : \"Lyon\",\n \"short_name\" : \"Lyon\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Rhône\",\n \"short_name\" : \"Rhône\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n },\n {\n \"long_name\" : \"69007\",\n \"short_name\" : \"69007\",\n \"types\" : [ \"postal_code\" ]\n }\n ],\n \"formatted_address\" : \"10 Rue Jangot, 69007 Lyon, France\",\n \"geometry\" : {\n \"location\" : {\n \"lat\" : 45.75164940000001,\n \"lng\" : 4.8424032\n },\n \"location_type\" : \"ROOFTOP\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 45.75299838029151,\n \"lng\" : 4.843752180291502\n },\n \"southwest\" : {\n \"lat\" : 45.75030041970851,\n \"lng\" : 4.841054219708497\n }\n }\n },\n \"place_id\" : \"ChIJtW0QikTq9EcRLI4Vy6bRx0U\",\n \"plus_code\" : {\n \"compound_code\" : \"QR2R+MX Lyon, France\",\n \"global_code\" : \"8FQ6QR2R+MX\"\n },\n \"types\" : [ \"street_address\" ]\n }\n ],\n \"status\" : \"OK\"\n}\n", "headers": { "Content-Type": "application/json; charset=UTF-8", - "Date": "Wed, 13 Mar 2019 17:50:19 GMT", - "Expires": "Thu, 14 Mar 2019 17:50:19 GMT", + "Date": "Thu, 22 Aug 2019 13:05:39 GMT", + "Expires": "Thu, 22 Aug 2019 13:06:09 GMT", + "Cache-Control": "public, max-age=30", "Access-Control-Allow-Origin": "*", "Server": "mafe", - "X-XSS-Protection": "1; mode=block", + "X-XSS-Protection": "0", "X-Frame-Options": "SAMEORIGIN", - "Server-Timing": "gfet4t7; dur=52", - "Cache-Control": "public, max-age=86400", - "Age": "17", - "Alt-Svc": "quic=\":443\"; ma=2592000; v=\"46,44,43,39\"", + "Server-Timing": "gfet4t7; dur=44", + "Alt-Svc": "quic=\":443\"; ma=2592000; v=\"46,43,39\"", "Accept-Ranges": "none", "Vary": "Accept-Encoding", "Transfer-Encoding": "chunked" @@ -30,5 +29,35 @@ "status_code": 200, "type": "ok" } + }, + { + "request": { + "body": "", + "headers": [], + "method": "get", + "options": [], + "request_body": "", + "url": "https://maps.googleapis.com/maps/api/place/details/json?key=toto&placeid=ChIJtW0QikTq9EcRLI4Vy6bRx0U" + }, + "response": { + "binary": false, + "body": "{\n \"html_attributions\" : [],\n \"result\" : {\n \"address_components\" : [\n {\n \"long_name\" : \"10\",\n \"short_name\" : \"10\",\n \"types\" : [ \"street_number\" ]\n },\n {\n \"long_name\" : \"Rue Jangot\",\n \"short_name\" : \"Rue Jangot\",\n \"types\" : [ \"route\" ]\n },\n {\n \"long_name\" : \"Lyon\",\n \"short_name\" : \"Lyon\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Rhône\",\n \"short_name\" : \"Rhône\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"Auvergne-Rhône-Alpes\",\n \"short_name\" : \"Auvergne-Rhône-Alpes\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"France\",\n \"short_name\" : \"FR\",\n \"types\" : [ \"country\", \"political\" ]\n },\n {\n \"long_name\" : \"69007\",\n \"short_name\" : \"69007\",\n \"types\" : [ \"postal_code\" ]\n }\n ],\n \"adr_address\" : \"\\u003cspan class=\\\"street-address\\\"\\u003e10 Rue Jangot\\u003c/span\\u003e, \\u003cspan class=\\\"postal-code\\\"\\u003e69007\\u003c/span\\u003e \\u003cspan class=\\\"locality\\\"\\u003eLyon\\u003c/span\\u003e, \\u003cspan class=\\\"country-name\\\"\\u003eFrance\\u003c/span\\u003e\",\n \"formatted_address\" : \"10 Rue Jangot, 69007 Lyon, France\",\n \"geometry\" : {\n \"location\" : {\n \"lat\" : 45.75164940000001,\n \"lng\" : 4.842403200000001\n },\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 45.7530412802915,\n \"lng\" : 4.843668630291503\n },\n \"southwest\" : {\n \"lat\" : 45.75034331970851,\n \"lng\" : 4.840970669708498\n }\n }\n },\n \"icon\" : \"https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png\",\n \"id\" : \"61b9418d092d2ed05ddd65a55dddefda5b9628cc\",\n \"name\" : \"10 Rue Jangot\",\n \"place_id\" : \"ChIJtW0QikTq9EcRLI4Vy6bRx0U\",\n \"plus_code\" : {\n \"compound_code\" : \"QR2R+MX Lyon, France\",\n \"global_code\" : \"8FQ6QR2R+MX\"\n },\n \"reference\" : \"ChIJtW0QikTq9EcRLI4Vy6bRx0U\",\n \"scope\" : \"GOOGLE\",\n \"types\" : [ \"street_address\" ],\n \"url\" : \"https://maps.google.com/?q=10+Rue+Jangot,+69007+Lyon,+France&ftid=0x47f4ea448a106db5:0x45c7d1a6cb158e2c\",\n \"utc_offset\" : 120,\n \"vicinity\" : \"Lyon\"\n },\n \"status\" : \"OK\"\n}\n", + "headers": { + "Content-Type": "application/json; charset=UTF-8", + "Date": "Thu, 22 Aug 2019 13:05:39 GMT", + "Expires": "Thu, 22 Aug 2019 13:10:39 GMT", + "Cache-Control": "public, max-age=300", + "Server": "scaffolding on HTTPServer2", + "X-XSS-Protection": "0", + "X-Frame-Options": "SAMEORIGIN", + "Server-Timing": "gfet4t7; dur=86", + "Alt-Svc": "quic=\":443\"; ma=2592000; v=\"46,43,39\"", + "Accept-Ranges": "none", + "Vary": "Accept-Language,Accept-Encoding", + "Transfer-Encoding": "chunked" + }, + "status_code": 200, + "type": "ok" + } } -] +] \ No newline at end of file diff --git a/test/mobilizon/service/geospatial/google_maps_test.exs b/test/mobilizon/service/geospatial/google_maps_test.exs index c8adb354d..8cab24600 100644 --- a/test/mobilizon/service/geospatial/google_maps_test.exs +++ b/test/mobilizon/service/geospatial/google_maps_test.exs @@ -43,7 +43,7 @@ defmodule Mobilizon.Service.Geospatial.GoogleMapsTest do use_cassette "geospatial/google_maps/search" do assert %Address{ locality: "Lyon", - description: "10 Rue Jangot, 69007 Lyon, France", + description: "10 Rue Jangot", region: "Auvergne-Rhône-Alpes", country: "France", postal_code: "69007", @@ -52,8 +52,13 @@ defmodule Mobilizon.Service.Geospatial.GoogleMapsTest do coordinates: {4.8424032, 45.75164940000001}, properties: %{}, srid: 4326 - } - } == GoogleMaps.search("10 rue Jangot", api_key: "toto") |> hd + }, + origin_id: "gm:ChIJtW0QikTq9EcRLI4Vy6bRx0U" + } == + GoogleMaps.search("10 rue Jangot", + api_key: "toto" + ) + |> hd end end @@ -61,16 +66,17 @@ defmodule Mobilizon.Service.Geospatial.GoogleMapsTest do use_cassette "geospatial/google_maps/geocode" do assert %Address{ locality: "Lyon", - description: "10 Rue Jangot, 69007 Lyon, France", + description: "10bis Rue Jangot", region: "Auvergne-Rhône-Alpes", country: "France", postal_code: "69007", - street: "10 Rue Jangot", + street: "10bis Rue Jangot", geom: %Geo.Point{ - coordinates: {4.8424967, 45.751725}, + coordinates: {4.8424966, 45.751725}, properties: %{}, srid: 4326 - } + }, + origin_id: "gm:ChIJrW0QikTq9EcR96jk2OnO75w" } == GoogleMaps.geocode(4.842569, 45.751718, api_key: "toto") |> hd diff --git a/test/mobilizon/service/geospatial/nominatim_test.exs b/test/mobilizon/service/geospatial/nominatim_test.exs index 169b2c5aa..11116072a 100644 --- a/test/mobilizon/service/geospatial/nominatim_test.exs +++ b/test/mobilizon/service/geospatial/nominatim_test.exs @@ -39,7 +39,8 @@ defmodule Mobilizon.Service.Geospatial.NominatimTest do coordinates: {4.8425657, 45.7517141}, properties: %{}, srid: 4326 - } + }, + origin_id: "osm:3078260611" } == Nominatim.search("10 rue Jangot") |> hd end end @@ -58,7 +59,8 @@ defmodule Mobilizon.Service.Geospatial.NominatimTest do coordinates: {4.8425657, 45.7517141}, properties: %{}, srid: 4326 - } + }, + origin_id: "osm:3078260611" } == Nominatim.geocode(4.842569, 45.751718) |> hd