Added borderpoint and trench coords to hausnummer
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class HausnummerAddBorderpointLatLong extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
$table = $this->table("Hausnummer");
|
||||
$table->addColumn("borderpoint_lat", "decimal",["null" => true, "default" => null, "precision" => 15, "scale" => 10, "after" => "gps_long"]);
|
||||
$table->addColumn("borderpoint_long", "decimal", ["null" => true, "default" => null, "precision" => 15, "scale" => 10, "after" => "borderpoint_lat"]);
|
||||
$table->addColumn("trenches", "json", ["null" => true, "default" => null, "after" => "borderpoint_long"]);
|
||||
$table->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
$table = $this->table("Hausnummer");
|
||||
//$table->removeColumn("trenches");
|
||||
$table->removeColumn("borderpoint_long");
|
||||
$table->removeColumn("borderpoint_lat");
|
||||
$table->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,8 +38,10 @@ if($argc > 1) {
|
||||
}
|
||||
}
|
||||
|
||||
//$netowners = ["estmk", "rml"];
|
||||
$netowners = ["estmk"];
|
||||
|
||||
foreach(["estmk", "rml"] as $apiOwner) {
|
||||
foreach($netowners as $apiOwner) {
|
||||
$apiEdition = "prod";
|
||||
$apiData = TT_RIMO_API_CREDS[$apiOwner][$apiEdition];
|
||||
|
||||
@@ -54,6 +56,7 @@ foreach(["estmk", "rml"] as $apiOwner) {
|
||||
$epGetBuildings = $apiUrl.RIMO_API_JSON_EP_GET_BUILDINGS;
|
||||
$epGetWorkorders = $apiUrl.RIMO_API_JSON_EP_QUERY_WORKORDERS;
|
||||
$epGetService = $apiUrl.RIMO_API_JSON_EP_QUERY_SERVICE;
|
||||
$epGetGeoJsonForBuilding = $apiUrl.RIMO_API_JSON_EP_GET_JSON_FOR_BUILDING;
|
||||
|
||||
$import_count = 0;
|
||||
|
||||
@@ -362,7 +365,10 @@ foreach(["estmk", "rml"] as $apiOwner) {
|
||||
|
||||
}
|
||||
|
||||
// get workorders
|
||||
/*
|
||||
* get workorders
|
||||
*/
|
||||
|
||||
$params = $baseParams;
|
||||
$params["buildingId"] = $rimo_building_id;
|
||||
$qs = http_build_query($params);
|
||||
@@ -418,7 +424,67 @@ foreach(["estmk", "rml"] as $apiOwner) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get Geodata
|
||||
*/
|
||||
$params = $baseParams;
|
||||
$params["buildingId"] = $rimo_building_id;
|
||||
$qs = http_build_query($params);
|
||||
|
||||
$req_url = $epGetGeoJsonForBuilding."?".$qs;
|
||||
$req_ctx = stream_context_create($ctxOptsGet);
|
||||
|
||||
//echo $req_url."\n";
|
||||
$responseText = file_get_contents($req_url, false, $req_ctx);
|
||||
|
||||
if($responseText === false) {
|
||||
//echo "Error fetching Workorders for building $rimo_building_id\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$geodataResponse = json_decode($responseText);
|
||||
|
||||
//print_r($geodataResponse);exit;
|
||||
|
||||
if(is_object($geodataResponse)) {
|
||||
if(property_exists($geodataResponse, "homeSection")) {
|
||||
|
||||
}
|
||||
if(property_exists($geodataResponse, "borderPoint")) {
|
||||
if(property_exists($geodataResponse->borderPoint, "features") && is_array($geodataResponse->borderPoint->features)) {
|
||||
foreach($geodataResponse->borderPoint->features as $feature) {
|
||||
$coords = $feature->geometry->coordinates;
|
||||
//var_dump($coords);exit;
|
||||
$long = $coords[0];
|
||||
$lat = $coords[1];
|
||||
if($hausnummer->borderpoint_lat != $lat || $hausnummer->borderpoint_long != $long) {
|
||||
$hausnummer->borderpoint_lat = $lat;
|
||||
$hausnummer->borderpoint_long = $long;
|
||||
$hausnummer->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(property_exists($geodataResponse, "trenches") && $geodataResponse->trenches->features) {
|
||||
$trenches = [];
|
||||
foreach($geodataResponse->trenches->features as $feature) {
|
||||
$feature_coords = [];
|
||||
foreach($feature->geometry->coordinates as $coord) {
|
||||
$long = $coords[0];
|
||||
$lat = $coords[1];
|
||||
$feature_coords[] = [$lat, $long];
|
||||
}
|
||||
$trenches[] = $feature_coords;
|
||||
}
|
||||
if(count($trenches)) {
|
||||
//var_dump($trenches);exit;
|
||||
$hausnummer->trenches = json_encode($trenches);
|
||||
$hausnummer->save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "Cluster $cluster_rimo_id ($cluster_name): $hausnummer_count Buildings; $hausnummer_found_count Buildings verarbeitet; $homes_count Homes verarbeitet.\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user