141 lines
8.5 KiB
HTML
141 lines
8.5 KiB
HTML
<!DOCTYPE html>
|
|
<html class="writer-html5" lang="en" >
|
|
<head>
|
|
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Google Maps API — Usse 1 documentation</title>
|
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
|
|
<!--[if lt IE 9]>
|
|
<script src="_static/js/html5shiv.min.js"></script>
|
|
<![endif]-->
|
|
|
|
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
|
|
<script src="_static/jquery.js"></script>
|
|
<script src="_static/underscore.js"></script>
|
|
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
|
|
<script src="_static/doctools.js"></script>
|
|
<script src="_static/sphinx_highlight.js"></script>
|
|
<script src="_static/js/theme.js"></script>
|
|
<link rel="index" title="Index" href="genindex.html" />
|
|
<link rel="search" title="Search" href="search.html" />
|
|
<link rel="prev" title="Project Usse" href="index.html" />
|
|
</head>
|
|
|
|
<body class="wy-body-for-nav">
|
|
<div class="wy-grid-for-nav">
|
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
|
<div class="wy-side-scroll">
|
|
<div class="wy-side-nav-search" >
|
|
<a href="index.html" class="icon icon-home"> Usse
|
|
</a>
|
|
<div role="search">
|
|
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
|
|
<input type="text" name="q" placeholder="Search docs" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</div>
|
|
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
|
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
|
|
<ul class="current">
|
|
<li class="toctree-l1 current"><a class="current reference internal" href="#">Google Maps API</a><ul>
|
|
<li class="toctree-l2"><a class="reference internal" href="#using-the-google-api">Using the Google API</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="#google-ban">Google Ban</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
|
<a href="index.html">Usse</a>
|
|
</nav>
|
|
|
|
<div class="wy-nav-content">
|
|
<div class="rst-content">
|
|
<div role="navigation" aria-label="Page navigation">
|
|
<ul class="wy-breadcrumbs">
|
|
<li><a href="index.html" class="icon icon-home"></a></li>
|
|
<li class="breadcrumb-item active">Google Maps API</li>
|
|
<li class="wy-breadcrumbs-aside">
|
|
<a href="_sources/googlemaps.rst.txt" rel="nofollow"> View page source</a>
|
|
</li>
|
|
</ul>
|
|
<hr/>
|
|
</div>
|
|
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
|
<div itemprop="articleBody">
|
|
|
|
<section id="google-maps-api">
|
|
<h1>Google Maps API<a class="headerlink" href="#google-maps-api" title="Permalink to this heading"></a></h1>
|
|
<p><code class="docutils literal notranslate"><span class="pre">Google</span> <span class="pre">Maps</span></code> has a <em>free</em> api that can be used to calculate distance matrixes as well as show point on a map.
|
|
In order to use this API you will need to request an API key from the <a class="reference external" href="https://cloud.google.com/">google cloud console</a>.</p>
|
|
<p>This API can be used at a cost for each request, but Google gives ~200 dollars worth of request at the start of every month.</p>
|
|
<section id="using-the-google-api">
|
|
<h2>Using the Google API<a class="headerlink" href="#using-the-google-api" title="Permalink to this heading"></a></h2>
|
|
<p>For a quick test to see if it was possible to geolocate each house and calculate the distance. For this a simple python script was used.</p>
|
|
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">origin_locations</span> <span class="o">=</span> <span class="p">{</span>
|
|
<span class="s2">"nfi_location"</span> <span class="p">:</span> <span class="p">(</span><span class="mf">52.044867266861466</span><span class="p">,</span> <span class="mf">4.3585175985355225</span><span class="p">),</span>
|
|
<span class="s2">"hoogstraat_location"</span> <span class="p">:</span> <span class="p">(</span><span class="mf">52.08725689123654</span><span class="p">,</span> <span class="mf">5.147180442716177</span><span class="p">),</span>
|
|
<span class="s2">"bakkersdijk_location"</span> <span class="p">:</span> <span class="p">(</span><span class="mf">51.85802695253161</span><span class="p">,</span> <span class="mf">4.482033956202426</span><span class="p">),</span>
|
|
<span class="s2">"korhoen_location"</span> <span class="p">:</span> <span class="p">(</span><span class="mf">52.5219455005375</span><span class="p">,</span> <span class="mf">5.732514040876346</span><span class="p">),</span>
|
|
<span class="s2">"harde_location"</span> <span class="p">:</span> <span class="p">(</span><span class="mf">52.41650138296019</span><span class="p">,</span> <span class="mf">5.870995170999243</span><span class="p">)</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="k">def</span> <span class="nf">get_distances</span><span class="p">(</span><span class="n">out_dict</span><span class="p">,</span> <span class="n">destination_location</span><span class="p">):</span>
|
|
<span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">origin_locations</span><span class="p">:</span>
|
|
<span class="n">distance</span> <span class="o">=</span> <span class="n">gmaps</span><span class="o">.</span><span class="n">distance_matrix</span><span class="p">(</span><span class="n">origin_locations</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">destination_location</span><span class="p">,</span> <span class="n">mode</span> <span class="o">=</span> <span class="s1">'driving'</span><span class="p">)</span>
|
|
<span class="n">out_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">distance</span><span class="p">[</span><span class="s1">'rows'</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="s1">'elements'</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>We can do about 40.000 request for free each month. With about 1200 houses and 6 requests per house that would mean up to 7000 requests.
|
|
That is enough to build a quick PoC to see if this method would work.</p>
|
|
<img alt="_images/poc_houses_on_maps.png" src="_images/poc_houses_on_maps.png" />
|
|
<p>This works and a lot of houses are shown on google maps with markers.</p>
|
|
</section>
|
|
<section id="google-ban">
|
|
<h2>Google Ban<a class="headerlink" href="#google-ban" title="Permalink to this heading"></a></h2>
|
|
<p>Another result of this action was a Ban from google.
|
|
The reason for this was that I did not read the terms of use.
|
|
You are allowed to do 40K requests for free every month, just not several thousand in a few minutes. Oops.</p>
|
|
<img alt="_images/ban_google.png" src="_images/ban_google.png" />
|
|
<p>Because we want to do more than 40k requests and dont want to pay for these requests, the project was switched to <strong>O</strong>pen <strong>S</strong>treet <strong>M</strong>ap(OSM)</p>
|
|
</section>
|
|
</section>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
|
|
<a href="index.html" class="btn btn-neutral float-left" title="Project Usse" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
|
|
</div>
|
|
|
|
<hr/>
|
|
|
|
<div role="contentinfo">
|
|
<p>© Copyright 2023, Eljakim.</p>
|
|
</div>
|
|
|
|
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
|
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
|
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
|
|
|
|
|
</footer>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
<script>
|
|
jQuery(function () {
|
|
SphinxRtdTheme.Navigation.enable(true);
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html> |