Map Real locations && home page pin points

master
NoNameGuy 2017-06-09 16:02:50 +01:00
parent 403bc1e2b5
commit 169a9e13bb
15 changed files with 75172 additions and 18 deletions

View File

@ -15,9 +15,15 @@ use GuzzleHttp\Client;
use GuzzleHttp;
use Symfony\Component\DomCrawler\Crawler;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Storage;
use App\District;
use App\Station;
use File;
use \RecursiveIteratorIterator;
use \RecursiveArrayIterator;
class LandingController extends BaseController
{
@ -456,4 +462,15 @@ $uniqueMatch1 = array();
}
}
public function getJsonOpenMaps()
{
$file = File::get('../public/files/export.json');
$contents = file_get_contents('../public/files/export.json',true);
$json = json_decode($contents, true);
print_r( $json['elements'][0]);
}
}

View File

@ -24,12 +24,13 @@ class LocationTableSeeder extends Seeder
$maxLatitudeSouth = 38.501;
$minLongitudeSouth = -8.756;
$maxLongitudeSouth = -7.075;
$minLatitudeWest = 38.501;
$maxLatitudeWest = 39.419;
$minLongitudeWest = -9.305;
$maxLongitudeWest = -8.756;
/*
//North
for ($i = 0; $i < 1000; $i++) {
$array = array(['latitude' => $this->randomCoordinate($minLatitudeNorth, $maxLatitudeNorth),
@ -57,9 +58,28 @@ class LocationTableSeeder extends Seeder
'longitude' => $this->randomCoordinate($minLongitudeWest, $maxLongitudeWest)]);
DB::table('location')->insert($array);
}
}
*/
$file = File::get('public/files/export.json');
$contents = file_get_contents('public/files/export.json',true);
$json = json_decode($contents, true);
for ($i=0; $i < 8500; $i++) {
if (isset($json['elements'][$i]['lat']) && isset($json['elements'][$i]['lon'])) {
$array = array(['latitude' => $json['elements'][$i]['lat'],
'longitude' => $json['elements'][$i]['lon']]);
DB::table('location')->insert($array);
}
}
}
/*
private function randomCoordinate ($min,$max) {
return ($min + lcg_value()*(abs($max - $min)));
}
*/
}

View File

@ -5,7 +5,7 @@ use Illuminate\Database\Seeder;
class StationTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
@ -14,7 +14,8 @@ class StationTableSeeder extends Seeder
public function run()
{
for ($i = 0; $i < DB::table('location')->count(); $i++) {
for ($j=0; $j < 5; $j++) {
for ($j=0; $j < 5; $j++) {
$brand = $this->randomBrand();
$location = $this->generateRandomNumber(1,10);
$district = $this->generateRandomNumber(1,18);
$fuel_price = $this->generateRandomNumber(1,10);
@ -22,9 +23,9 @@ class StationTableSeeder extends Seeder
$schedule = $this->generateRandomNumber(1,10);
}
DB::table('station')->insert([
DB::table('station')->insert([
'name' => "a$i",
'brand' => "galp",
'brand' => $brand,
'location' => $location,
'district' => $district,
'fuel_price' => $fuel_price,
@ -42,4 +43,13 @@ class StationTableSeeder extends Seeder
return ($min + lcg_value()*(abs($max - $min)));
}
private function randomBrand()
{
# code...
$var = file_get_contents('public/files/brand.txt'); //Take the contents from the file to the variable
$result = explode(',',$var); //Split it by ','
return $result[array_rand($result)]; //Return a random entry from the array.
}
}

BIN
laravel/public/files/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
laravel/public/files/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
laravel/public/files/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
laravel/public/files/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
laravel/public/files/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
[{"cod_distrito": "01", "nome_distrito": "Aveiro"}, {"cod_distrito": "02", "nome_distrito": "Beja"}, {"cod_distrito": "03", "nome_distrito": "Braga"}, {"cod_distrito": "04", "nome_distrito": "Bragança"}, {"cod_distrito": "05", "nome_distrito": "Castelo Branco"}, {"cod_distrito": "06", "nome_distrito": "Coimbra"}, {"cod_distrito": "07", "nome_distrito": "Évora"}, {"cod_distrito": "08", "nome_distrito": "Faro"}, {"cod_distrito": "09", "nome_distrito": "Guarda"}, {"cod_distrito": "10", "nome_distrito": "Leiria"}, {"cod_distrito": "11", "nome_distrito": "Lisboa"}, {"cod_distrito": "12", "nome_distrito": "Portalegre"}, {"cod_distrito": "13", "nome_distrito": "Porto"}, {"cod_distrito": "14", "nome_distrito": "Santarém"}, {"cod_distrito": "15", "nome_distrito": "Setúbal"}, {"cod_distrito": "16", "nome_distrito": "Viana do Castelo"}, {"cod_distrito": "17", "nome_distrito": "Vila Real"}, {"cod_distrito": "18", "nome_distrito": "Viseu"}, {"cod_distrito": "31", "nome_distrito": "Ilha da Madeira"}, {"cod_distrito": "32", "nome_distrito": "Ilha de Porto Santo"}, {"cod_distrito": "41", "nome_distrito": "Ilha de Santa Maria"}, {"cod_distrito": "42", "nome_distrito": "Ilha de São Miguel"}, {"cod_distrito": "43", "nome_distrito": "Ilha Terceira"}, {"cod_distrito": "44", "nome_distrito": "Ilha da Graciosa"}, {"cod_distrito": "45", "nome_distrito": "Ilha de São Jorge"}, {"cod_distrito": "46", "nome_distrito": "Ilha do Pico"}, {"cod_distrito": "47", "nome_distrito": "Ilha do Faial"}, {"cod_distrito": "48", "nome_distrito": "Ilha das Flores"}, {"cod_distrito": "49", "nome_distrito": "Ilha do Corvo"}]

View File

@ -0,0 +1,76 @@
AGIP
,AGRILOJA
,AGRIPOWER
,AGROCAMPREST
,ALL COMBUSTÍVEIS
,ALVES BANDEIRA
,ANIBAL ANTUNES BANDEIRA
,ATLANTIC OIL
,AUTO JULIO
,AVIA
,AZORIA
,BEQ
,BOMBAGÁS
,BP
,BXPRESS
,CARLOS BALTAZAR
,CARRASQUINHO & FILHOS
,CEPSA
,CIDADE N'ALDEIA
,CIPOL
,COMBUSTIVEIS PERELHAL
,CONTINENTE
,CREIXOAUTO
,DOUROGAS NATURAL
,DPC
,ECOBRENT
,ECOMARCHÉ
,ESPERTOCAR
,ESSO
,ETC
,FEIRA NOVA
,FREITAS
,FUELTEJO
,GALP
,GAPOR
,GASOLAR
,GASPE
,GASPROCAR
,G-ENERGY
,Genérico
,GOTA
,HM COMBUSTÍVEIS
,ILÍDIO MOTA
,INTERMARCHÉ
,JUMBO
,LECLERC
,LUBRIDÃO
,LUSIADAGÁS
,NAUTIGÁS
,NEVES E CAPOTE
,NOVOSOL
,OFIMAQ
,OLEOFAT
,OZ Energia
,PETRIN
,PETRO BASTO
,PETROIBÉRICA
,PETROINSUA
,PETROVARIANTE
,PETROVAZ
,PINGO DOCE
,PRIO
,Q8
,RECHEIO
,REDE ENERGIA
,REDIL
,RELENHA
,REPSOL
,SCAM
,SOPOR
,TOP FUEL
,TRANSFORPEL
,TRAVESSO
,TUACAR
,VIBAGÁS
,VMF PETRÓLEOS

File diff suppressed because it is too large Load Diff

View File

@ -104,21 +104,24 @@ var js = $(document).ready(function(){
var markers=new Array();
markers.push(getStations());
//console.log(markers);
//label: labels[labelIndex++ % labels.length],
placeMarker(map, markers);
}
function placeMarker(map, markers) {
var myLatLng = {"lat": 39.7495, "lng":-8.8077};
var labels = '12345';
var labelIndex = 0;
markers.forEach(function(marker){
for (var i = 0; i < marker.length; i++) {
console.log(parseFloat(marker[i].latitude)+" lng"+ parseFloat(marker[i].longitude));
new google.maps.Marker({
position: {"lat": parseFloat(marker[i].latitude), "lng": parseFloat(marker[i].longitude)},
map: map,
title: marker[i].stationName
});
label: labels[labelIndex++ % labels.length],
map: map,
title: marker[i].stationName
});
}
});
}

View File

@ -11,7 +11,7 @@
<div class="col-sm-8 text-left">
<h1 class="center">Preço dos Combustíveis</h1>
<a href="{{action('LandingController@fetchStationData')}}">Fetch data station</a>
<a href="{{action('LandingController@getJsonOpenMaps')}}">Fetch data station</a>
<hr>
@ -78,12 +78,22 @@
<input type="hidden" name="brand" value="">
<button id="landingBack">Back</button>
</form>
<p>Mais baratas ()</p>
@foreach($stations as $station)
Nome: {{$station->stationName}}<br>
Preço: {{$station->fuelPrice}}<br>
Services: {{$station->services}}<br>
@endforeach
<h3 class="text-center">Mais baratas ()</h3>
<div class="form-group">
@foreach($stations as $key=>$station)
<div class="well well-lg">
<label for="nome">Nome: </label>
{{$station->stationName}}<br>
<label for="nome">Preço: </label>
{{$station->fuelPrice}}
<button type="button" class="btn btn-link" style="float:right">Detalhes</button>
<img src="../../files/{{$key+1}}.jpg" style="float:right"></img>
<br>
<label for="nome">Serviços: </label>
{{$station->services}}<br>
</div>
@endforeach
</div>
@endif
</div>
</div>

View File

@ -31,7 +31,7 @@ Route::get('/user/activation/{token}', 'Auth\RegisterController@userActivation')
Route::get('/', 'LandingController@index')->name('home');
Route::get('/fetchStation', 'LandingController@fetchStationData');#para apagar
Route::get('/fetchStation', 'LandingController@getJsonOpenMaps');
/*
Route::get('/login', 'Auth\LoginController@index');