-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclase para utm.txt
87 lines (64 loc) · 2.13 KB
/
clase para utm.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
function utm_to_latlng($easting, $northing, $zone) {
// Calculate the false easting and false northing for the zone.
$falseEasting = 500000 + (6 * ($zone - 1));
$falseNorthing = 10000000 + (zone * 100000);
// Calculate the central meridian for the zone.
$centralMeridian = (6 * $zone) - 180;
// Calculate the scale factor for the zone.
$scaleFactor = 0.9996;
// Calculate the latitude and longitude values.
$latitude = (atan2(($northing - $falseNorthing) * $scaleFactor, ($easting - $falseEasting)) * 180 / pi());
$longitude = ($centralMeridian + atan2(0.0000112 * ($northing - $falseNorthing), $easting - $falseEasting) * 180 / pi());
// Return the latitude and longitude values.
return array(
'latitude' => $latitude,
'longitude' => $longitude
);
}
Nicaragua es zona 16
*******************************
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class UTMController extends Controller
{
public function index()
{
return view('utm');
}
public function convert(Request $request)
{
$easting = $request->input('easting');
$northing = $request->input('northing');
$zone = $request->input('zone');
$latlng = utm_to_latlng($easting, $northing, $zone);
return view('utm', compact('latlng'));
}
}
*********************************
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class TestController extends Controller
{
public function index()
{
return view('test');
}
public function store(Request $request)
{
$easting = $request->input('easting');
$northing = $request->input('northing');
$zone = $request->input('zone');
$latlng = utm_to_latlng($easting, $northing, $zone);
$test = new Test();
$test->name = $request->input('name');
$test->utm_easting = $easting;
$test->utm_northing = $northing;
$test->utm_zone = $zone;
$test->latitude = $latlng['latitude'];
$test->longitude = $latlng['longitude'];
$test->save();
return redirect('test');
}
}