Compare commits
1 Commits
feature/Ma
...
5d2a6d045b
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d2a6d045b |
@@ -18,7 +18,7 @@ enum CmmsMachineStatus: int
|
|||||||
self::AMADE => 'آماده',
|
self::AMADE => 'آماده',
|
||||||
self::RESERVE => 'رزرو',
|
self::RESERVE => 'رزرو',
|
||||||
self::DAR_MAMORIAT => 'در ماموریت',
|
self::DAR_MAMORIAT => 'در ماموریت',
|
||||||
self::KHAREGE_AZ_RADE => 'خارج از محدوده',
|
self::KHAREGE_AZ_RADE => 'خارج از رده',
|
||||||
self::DAR_TAMIR => 'در تعمیر',
|
self::DAR_TAMIR => 'در تعمیر',
|
||||||
self::FOROKHTEH_SHODE => ' فروخته شده',
|
self::FOROKHTEH_SHODE => ' فروخته شده',
|
||||||
self::NIZE_BE_TAMIR => 'نیاز به تعمیر',
|
self::NIZE_BE_TAMIR => 'نیاز به تعمیر',
|
||||||
|
|||||||
@@ -2,16 +2,20 @@
|
|||||||
|
|
||||||
namespace App\Enums;
|
namespace App\Enums;
|
||||||
|
|
||||||
|
use function Symfony\Component\String\s;
|
||||||
|
|
||||||
enum MissionViolationStatus: int
|
enum MissionViolationStatus: int
|
||||||
{
|
{
|
||||||
case BEDON_EGHDAM = 0;
|
case BEDON_EGHDAM = 0;
|
||||||
case EGHDAM_SHODE = 1;
|
case EGHDAM_SHODE = 1;
|
||||||
|
case SABT_SHODE = 2;
|
||||||
|
|
||||||
public function label(): string
|
public function label(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::BEDON_EGHDAM => "بدون اقدام",
|
self::BEDON_EGHDAM => "بدون اقدام",
|
||||||
self::EGHDAM_SHODE => "اقدام شده",
|
self::EGHDAM_SHODE => "اقدام شده",
|
||||||
|
self::SABT_SHODE => "ثبت شده توسط حراست"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,8 +23,7 @@ class CMMSMachinesController extends Controller
|
|||||||
$request,
|
$request,
|
||||||
allowedFilters: ['*'],
|
allowedFilters: ['*'],
|
||||||
allowedSortings: ['*'],
|
allowedSortings: ['*'],
|
||||||
allowedSelects: ['machine_code', 'id', 'plak_number', 'car_name', 'car_type', 'status',
|
allowedSelects: ['machine_code', 'id', 'plak_number', 'car_name', 'car_type', 'status'],
|
||||||
'province_id', 'city_id', 'station_id', 'status','driver_name'],
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\V3;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Http\Traits\ApiResponse;
|
|
||||||
use App\Models\City;
|
|
||||||
use App\Models\Province;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class CityController extends Controller
|
|
||||||
{
|
|
||||||
use ApiResponse;
|
|
||||||
|
|
||||||
public function list(Request $request)
|
|
||||||
{
|
|
||||||
return $this->successResponse(City::query()->where('cities.province_id', $request->query('province_id'))->get(['id', 'name_fa']));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -72,18 +72,6 @@ class ReportMachineController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws Exception
|
|
||||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
|
||||||
*/
|
|
||||||
public function countryMachineTypesActivityExcel(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
|
|
||||||
{
|
|
||||||
$data = $reportMachineService->countryMachineTypesActivity($request);
|
|
||||||
$name = 'گزارش ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
|
|
||||||
|
|
||||||
return Excel::download(new machineReport($data), $name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provinceMachineTypesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
|
public function provinceMachineTypesActivity(Request $request, ReportMachineService $reportMachineService): JsonResponse
|
||||||
{
|
{
|
||||||
return $this->successResponse([
|
return $this->successResponse([
|
||||||
@@ -97,16 +85,4 @@ class ReportMachineController extends Controller
|
|||||||
// ->get(['id', 'name_fa'])
|
// ->get(['id', 'name_fa'])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws Exception
|
|
||||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
|
||||||
*/
|
|
||||||
public function provinceMachineTypesActivityExcel(Request $request, ReportMachineService $reportMachineService): BinaryFileResponse
|
|
||||||
{
|
|
||||||
$data = $reportMachineService->provinceMachineTypesActivity($request);
|
|
||||||
$name = 'گزارش ماشین آلات'.verta()->now()->format('Y-m-d H-i').'.xlsx';
|
|
||||||
|
|
||||||
return Excel::download(new machineReport($data), $name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class RequestPortalController extends Controller
|
|||||||
'request_date' => now(),
|
'request_date' => now(),
|
||||||
'description' => $request->description,
|
'description' => $request->description,
|
||||||
'end_point' => $request->end_point,
|
'end_point' => $request->end_point,
|
||||||
'area' => json_encode($request->area),
|
'area' => $request->area,
|
||||||
'category_id' => $request->category_id,
|
'category_id' => $request->category_id,
|
||||||
'category_name' => MissionCategory::name($request->category_id),
|
'category_name' => MissionCategory::name($request->category_id),
|
||||||
'explanation' => $request->explanation,
|
'explanation' => $request->explanation,
|
||||||
@@ -136,7 +136,7 @@ class RequestPortalController extends Controller
|
|||||||
'request_date' => now(),
|
'request_date' => now(),
|
||||||
'description' => $request->description,
|
'description' => $request->description,
|
||||||
'end_point' => $request->end_point,
|
'end_point' => $request->end_point,
|
||||||
'area' => json_encode($request->area),
|
'area' => $request->area,
|
||||||
'category_id' => $request->category_id,
|
'category_id' => $request->category_id,
|
||||||
'category_name' => MissionCategory::name($request->category_id),
|
'category_name' => MissionCategory::name($request->category_id),
|
||||||
'explanation' => $request->explanation,
|
'explanation' => $request->explanation,
|
||||||
@@ -174,7 +174,7 @@ class RequestPortalController extends Controller
|
|||||||
'end_date' => $request->end_date,
|
'end_date' => $request->end_date,
|
||||||
'description' => $request->description,
|
'description' => $request->description,
|
||||||
'end_point' => $request->end_point,
|
'end_point' => $request->end_point,
|
||||||
'area' => json_encode($request->area),
|
'area' => $request->area,
|
||||||
'category_id' => $request->category_id,
|
'category_id' => $request->category_id,
|
||||||
'category_name' => MissionCategory::name($request->category_id),
|
'category_name' => MissionCategory::name($request->category_id),
|
||||||
'explanation' => $request->explanation,
|
'explanation' => $request->explanation,
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class ViolationManagementController extends Controller
|
|||||||
'edare_shahri_name' => $user->edarate_shahri_name ?? null,
|
'edare_shahri_name' => $user->edarate_shahri_name ?? null,
|
||||||
'zone' => $zone,
|
'zone' => $zone,
|
||||||
'zone_fa' => MissionZones::name($zone),
|
'zone_fa' => MissionZones::name($zone),
|
||||||
|
'area' => $request->area,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'type_fa' => MissionTypes::name($type),
|
'type_fa' => MissionTypes::name($type),
|
||||||
'start_date' => $request->start_date,
|
'start_date' => $request->start_date,
|
||||||
@@ -103,7 +104,7 @@ class ViolationManagementController extends Controller
|
|||||||
'machine_id'=> CMMSMachine::query()->where('machine_code', '=', $request->machine_code)->value('id'),
|
'machine_id'=> CMMSMachine::query()->where('machine_code', '=', $request->machine_code)->value('id'),
|
||||||
'machine_code'=> $request->machine_code,
|
'machine_code'=> $request->machine_code,
|
||||||
'type'=> MissionViolationType::KHOROJ_BEDONE_MOGAVEZ->value,
|
'type'=> MissionViolationType::KHOROJ_BEDONE_MOGAVEZ->value,
|
||||||
'status' => MissionViolationStatus::BEDON_EGHDAM->value,
|
'status' => MissionViolationStatus::SABT_SHODE->value,
|
||||||
'request_date' => now(),
|
'request_date' => now(),
|
||||||
'km' => $request->km,
|
'km' => $request->km,
|
||||||
'gps' => 0,
|
'gps' => 0,
|
||||||
@@ -111,6 +112,9 @@ class ViolationManagementController extends Controller
|
|||||||
'province_name' => $user->province_fa,
|
'province_name' => $user->province_fa,
|
||||||
'city_id' => $user->city_id,
|
'city_id' => $user->city_id,
|
||||||
'city_name' => $user->city_fa,
|
'city_name' => $user->city_fa,
|
||||||
|
'station_id' => $user->station_id,
|
||||||
|
'station_name' => RahdariPoint::query()->find($user->station_id)->name,
|
||||||
|
'exit_time' => $request->exit_time,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
@@ -125,7 +129,6 @@ class ViolationManagementController extends Controller
|
|||||||
{
|
{
|
||||||
$violation->update([
|
$violation->update([
|
||||||
'enter_time' => $request->enter_time,
|
'enter_time' => $request->enter_time,
|
||||||
'exit_time' => $request->exit_time,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\V3;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Http\Traits\ApiResponse;
|
|
||||||
use App\Models\City;
|
|
||||||
use App\Models\Province;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class ProvinceController extends Controller
|
|
||||||
{
|
|
||||||
use ApiResponse;
|
|
||||||
|
|
||||||
public function list()
|
|
||||||
{
|
|
||||||
return $this->successResponse(Province::all(['id', 'name_fa']));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -35,12 +35,9 @@ class ContinueMissionRequest extends FormRequest
|
|||||||
'end_date' => 'required|date',
|
'end_date' => 'required|date',
|
||||||
'description' => 'string',
|
'description' => 'string',
|
||||||
'end_point' => 'required|string',
|
'end_point' => 'required|string',
|
||||||
'area' => 'required|array',
|
'area' => 'required|string',
|
||||||
'area.type' => 'required|string',
|
|
||||||
'area.coordinates' => 'required|array',
|
|
||||||
'explanation' => 'required|string',
|
'explanation' => 'required|string',
|
||||||
'category_id' => 'required|in:1,2,3',
|
'category_id' => 'required|in:1,2,3',
|
||||||
'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,9 @@ class StoreRequest extends FormRequest
|
|||||||
'end_date' => 'required|date',
|
'end_date' => 'required|date',
|
||||||
'description' => 'string',
|
'description' => 'string',
|
||||||
'end_point' => 'required|string',
|
'end_point' => 'required|string',
|
||||||
'area' => 'required|array',
|
'area' => 'required|string',
|
||||||
'area.type' => 'required|string',
|
|
||||||
'area.coordinates' => 'required|array',
|
|
||||||
'explanation' => 'required|string',
|
'explanation' => 'required|string',
|
||||||
'category_id' => 'required|in:1,2,3',
|
'category_id' => 'required|in:1,2,3',
|
||||||
'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +55,12 @@ class StoreRequest extends FormRequest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (strtotime($this->end_date) < strtotime($this->start_date)) {
|
||||||
|
$validator->errors()->add(
|
||||||
|
'time',
|
||||||
|
'زمان پایان ماموریت باید بعد از زمان شروع ماموریت باشد.'
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,12 +35,9 @@ class UpdateRequest extends FormRequest
|
|||||||
'end_date' => 'required|date',
|
'end_date' => 'required|date',
|
||||||
'description' => 'string',
|
'description' => 'string',
|
||||||
'end_point' => 'required|string',
|
'end_point' => 'required|string',
|
||||||
'area' => 'required|array',
|
'area' => 'required|string',
|
||||||
'area.type' => 'required|string',
|
|
||||||
'area.coordinates' => 'required|array',
|
|
||||||
'explanation' => 'required|string',
|
'explanation' => 'required|string',
|
||||||
'category_id' => 'required|in:1,2,3',
|
'category_id' => 'required|in:1,2,3',
|
||||||
'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +56,12 @@ class UpdateRequest extends FormRequest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (strtotime($this->end_date) < strtotime($this->start_date)) {
|
||||||
|
$validator->errors()->add(
|
||||||
|
'time',
|
||||||
|
'زمان پایان ماموریت باید بعد از زمان شروع ماموریت باشد.'
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Http\Requests\V3\Mission\Violation;
|
namespace App\Http\Requests\V3\Mission\Violation;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Validator;
|
||||||
|
|
||||||
class NoProcessRequest extends FormRequest
|
class NoProcessRequest extends FormRequest
|
||||||
{
|
{
|
||||||
@@ -30,9 +32,7 @@ class NoProcessRequest extends FormRequest
|
|||||||
'start_date' => 'required|date',
|
'start_date' => 'required|date',
|
||||||
'end_date' => 'required|date|after:start_date|before:now',
|
'end_date' => 'required|date|after:start_date|before:now',
|
||||||
'end_point' => 'required|string',
|
'end_point' => 'required|string',
|
||||||
'area' => 'array',
|
'area' => 'required|string',
|
||||||
'area.type' => 'string',
|
|
||||||
'area.coordinates' => 'array',
|
|
||||||
'category_id' => 'required|in:1,2,3',
|
'category_id' => 'required|in:1,2,3',
|
||||||
'explanation' => 'required|string',
|
'explanation' => 'required|string',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ class StoreRequest extends FormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'machine_code' => 'required',
|
'exit_time' => 'required|date',
|
||||||
|
'machine_code' => 'required',
|
||||||
'km'=> 'string',
|
'km'=> 'string',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ class UpdateRequest extends FormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'exit_time' => 'date',
|
'enter_time' => 'required|date',
|
||||||
'enter_time' => 'date',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ class City extends Model
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $guarded = ['id'];
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
'name_en',
|
'name_en',
|
||||||
'feature_id',
|
'feature_id',
|
||||||
|
|||||||
@@ -28,13 +28,6 @@ class Mission extends Model
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function area(): Attribute
|
|
||||||
{
|
|
||||||
return Attribute::make(
|
|
||||||
get: fn($value) => json_decode($value, true)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function histories(): HasMany
|
public function histories(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(MissionHistory::class);
|
return $this->hasMany(MissionHistory::class);
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ class Province extends Model
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $guarded = ['id'];
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
'feature_id',
|
'feature_id',
|
||||||
//'center_lat',
|
//'center_lat',
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class ReportMachineService
|
|||||||
m.machine_code,
|
m.machine_code,
|
||||||
cm.car_name,
|
cm.car_name,
|
||||||
COUNT(*) AS missions,
|
COUNT(*) AS missions,
|
||||||
SUM(m.end_km - m.km) AS func
|
SUM(m.end_km - m.km) AS func,
|
||||||
FROM missions m
|
FROM missions m
|
||||||
JOIN cmms_machines cm ON cm.id = m.machine_id
|
JOIN cmms_machines cm ON cm.id = m.machine_id
|
||||||
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to
|
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to
|
||||||
@@ -59,7 +59,7 @@ class ReportMachineService
|
|||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
cm.car_type,
|
cm.car_type,
|
||||||
COUNT(*) AS missions,
|
COUNT(*) AS missions,
|
||||||
SUM(m.end_km - m.km) AS func
|
SUM(m.end_km - m.km) AS func,
|
||||||
FROM missions m
|
FROM missions m
|
||||||
JOIN cmms_machines cm ON cm.id = m.machine_id
|
JOIN cmms_machines cm ON cm.id = m.machine_id
|
||||||
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to
|
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to
|
||||||
@@ -80,7 +80,7 @@ class ReportMachineService
|
|||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
cm.car_type,
|
cm.car_type,
|
||||||
COUNT(*) AS missions,
|
COUNT(*) AS missions,
|
||||||
SUM(m.end_km - m.km) AS func
|
SUM(m.end_km - m.km) AS func,
|
||||||
FROM missions m
|
FROM missions m
|
||||||
JOIN cmms_machines cm ON cm.id = m.machine_id
|
JOIN cmms_machines cm ON cm.id = m.machine_id
|
||||||
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to AND province_id = :province_id
|
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to AND province_id = :province_id
|
||||||
@@ -102,7 +102,7 @@ class ReportMachineService
|
|||||||
m.driver_id,
|
m.driver_id,
|
||||||
m.driver_name,
|
m.driver_name,
|
||||||
COUNT(*) AS missions,
|
COUNT(*) AS missions,
|
||||||
SUM(m.end_km - m.km) AS func
|
SUM(m.end_km - m.km) AS func,
|
||||||
FROM missions m
|
FROM missions m
|
||||||
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to
|
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to
|
||||||
GROUP BY m.driver_id;";
|
GROUP BY m.driver_id;";
|
||||||
@@ -123,7 +123,7 @@ class ReportMachineService
|
|||||||
m.driver_id,
|
m.driver_id,
|
||||||
m.driver_name,
|
m.driver_name,
|
||||||
COUNT(*) AS missions,
|
COUNT(*) AS missions,
|
||||||
SUM(m.end_km - m.km) AS func
|
SUM(m.end_km - m.km) AS func,
|
||||||
FROM missions m
|
FROM missions m
|
||||||
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to AND province_id = :province_id
|
WHERE m.state_id = 4 AND m.start_time >= :from AND m.finish_time <= :to AND province_id = :province_id
|
||||||
GROUP BY m.driver_id;";
|
GROUP BY m.driver_id;";
|
||||||
|
|||||||
88
app/Services/PolylineEncoder.php
Normal file
88
app/Services/PolylineEncoder.php
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PolylineEncoder
|
||||||
|
*
|
||||||
|
* Encodes a list of latitude/longitude coordinates into an encoded polyline string.
|
||||||
|
*
|
||||||
|
* This implementation is compatible with Google's Polyline Algorithm Format:
|
||||||
|
* https://developers.google.com/maps/documentation/utilities/polylinealgorithm
|
||||||
|
*
|
||||||
|
* Example input:
|
||||||
|
* [
|
||||||
|
* [lat, lng],
|
||||||
|
* [lat, lng]
|
||||||
|
* ]
|
||||||
|
*
|
||||||
|
* or if `$lng_lat_format = true`:
|
||||||
|
* [
|
||||||
|
* [lng, lat],
|
||||||
|
* [lng, lat]
|
||||||
|
* ]
|
||||||
|
*
|
||||||
|
* @package App\Services
|
||||||
|
*/
|
||||||
|
class PolylineEncoder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Encode an array of coordinates into a polyline string.
|
||||||
|
*
|
||||||
|
* Each coordinate is encoded as a delta from the previous point,
|
||||||
|
* scaled by the given precision factor.
|
||||||
|
*
|
||||||
|
* @param array $coords Array of coordinate pairs:
|
||||||
|
* - default: [lat, lng]
|
||||||
|
* - if $lng_lat_format = true: [lng, lat]
|
||||||
|
* @param int $precision Number of decimal places to preserve (default: 6)
|
||||||
|
* @param bool $lng_lat_format If true, input is treated as [lng, lat] instead of [lat, lng]
|
||||||
|
*
|
||||||
|
* @return string Encoded polyline string
|
||||||
|
*/
|
||||||
|
public function encodePolyline(array $coords, int $precision = 6, bool $lng_lat_format = false): string
|
||||||
|
{
|
||||||
|
$factor = 10 ** $precision;
|
||||||
|
$output = '';
|
||||||
|
$prevLat = 0;
|
||||||
|
$prevLng = 0;
|
||||||
|
|
||||||
|
foreach ($coords as [$a, $b]) {
|
||||||
|
[$lat, $lng] = $lng_lat_format ? [$b, $a] : [$a, $b];
|
||||||
|
|
||||||
|
$output .= $this->encodeValue((int)round($lat * $factor) - $prevLat);
|
||||||
|
$output .= $this->encodeValue((int)round($lng * $factor) - $prevLng);
|
||||||
|
|
||||||
|
$prevLat = (int)round($lat * $factor);
|
||||||
|
$prevLng = (int)round($lng * $factor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes a single integer value using Google's polyline encoding algorithm.
|
||||||
|
*
|
||||||
|
* Steps:
|
||||||
|
* - Left shift the value
|
||||||
|
* - Invert bits if negative
|
||||||
|
* - Split into 5-bit chunks
|
||||||
|
* - Convert to ASCII characters
|
||||||
|
*
|
||||||
|
* @param int $value Signed integer delta to encode
|
||||||
|
*
|
||||||
|
* @return string Encoded character sequence
|
||||||
|
*/
|
||||||
|
public function encodeValue(int $value): string
|
||||||
|
{
|
||||||
|
$value = $value < 0 ? ~($value << 1) : ($value << 1);
|
||||||
|
$result = '';
|
||||||
|
|
||||||
|
while ($value >= 0x20) {
|
||||||
|
$result .= chr((0x20 | ($value & 0x1f)) + 63);
|
||||||
|
$value >>= 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result . chr($value + 63);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Http\Controllers\V3\Auth\LogoutController;
|
use App\Http\Controllers\V3\Auth\LogoutController;
|
||||||
use App\Http\Controllers\V3\CityController;
|
|
||||||
use App\Http\Controllers\V3\CMMSMachinesController;
|
use App\Http\Controllers\V3\CMMSMachinesController;
|
||||||
use App\Http\Controllers\V3\DamageManagementController;
|
use App\Http\Controllers\V3\DamageManagementController;
|
||||||
use App\Http\Controllers\V3\Dashboard\Accident\AccidentReceiptController;
|
use App\Http\Controllers\V3\Dashboard\Accident\AccidentReceiptController;
|
||||||
@@ -39,7 +38,6 @@ use App\Http\Controllers\V3\LogListManagementController;
|
|||||||
use App\Http\Controllers\V3\NotificationController;
|
use App\Http\Controllers\V3\NotificationController;
|
||||||
use App\Http\Controllers\V3\PermissionManagementController;
|
use App\Http\Controllers\V3\PermissionManagementController;
|
||||||
use App\Http\Controllers\V3\ProfileController;
|
use App\Http\Controllers\V3\ProfileController;
|
||||||
use App\Http\Controllers\V3\ProvinceController;
|
|
||||||
use App\Http\Controllers\V3\RahdaranController;
|
use App\Http\Controllers\V3\RahdaranController;
|
||||||
use App\Http\Controllers\V3\WebServices\RoadItemController;
|
use App\Http\Controllers\V3\WebServices\RoadItemController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
@@ -685,17 +683,3 @@ Route::get('/test', function () {
|
|||||||
$csvExporter = new \Laracsv\Export();
|
$csvExporter = new \Laracsv\Export();
|
||||||
$csvExporter->build(\App\Models\User::all(), ['id' => 'کد یکتا', 'username' => 'نام کاربری'])->download();
|
$csvExporter->build(\App\Models\User::all(), ['id' => 'کد یکتا', 'username' => 'نام کاربری'])->download();
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('provinces')
|
|
||||||
->name('provinces.')
|
|
||||||
->controller(ProvinceController::class)
|
|
||||||
->group(function () {
|
|
||||||
Route::get('/list', 'list')->name('list');
|
|
||||||
});
|
|
||||||
|
|
||||||
Route::prefix('cities')
|
|
||||||
->name('cities.')
|
|
||||||
->controller(CityController::class)
|
|
||||||
->group(function () {
|
|
||||||
Route::get('/list', 'list')->name('list');
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user