"Borrowed" pabst's UTM zone/band function and moved it from microdagr to map

This commit is contained in:
VKing 2015-05-10 21:45:49 +02:00
parent bcac56874b
commit 2dd42f828d
2 changed files with 18 additions and 23 deletions

View File

@ -9,10 +9,11 @@
* Return value:
* 0: Grid zone designator (String)
* 1: 100km square (String)
* 2: GZD + 100km sq. as a single string (String)
* Writes return values to GVAR(MGRS_data) if run on the current map
*/
#define DEBUG_MODE_FULL
// #define DEBUG_MODE_FULL
#include "script_component.hpp"
private ["_zone","_band","_GZD","_long","_lat","_UTM","_easting","_northing"];
@ -25,7 +26,7 @@ _lat = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "latitude");
// if (!isNil QEGVAR(weather,Latitude)) then {_lat = EGVAR(weather,Latitude)};
if (_map in ["Chernarus", "Bootcamp_ACR", "Woodland_ACR", "utes"]) then { _lat = 50; };
if (_map in ["Altis", "Stratis"]) then { _lat = 40; };
if (_map in ["Altis", "Stratis"]) then { _lat = 35; };
if (_map in ["Takistan", "Zargabad", "Mountains_ACR"]) then { _lat = 35; };
if (_map in ["Shapur_BAF", "ProvingGrounds_PMC"]) then { _lat = 35; };
if (_map in ["fallujah"]) then { _lat = 33; };
@ -50,9 +51,10 @@ if (_map in ["Kunduz"]) then { _lat = 37; };
_UTM = [_long,_lat] call BIS_fnc_posDegToUTM;
_easting = _UTM select 0;
_northing = _UTM select 1;
_zone = _UTM select 2;
// _zone = _UTM select 2;
TRACE_4("",_UTM,_easting,_northing,_zone);
/*
_band = switch (true) do {
case (_lat<-72): {"C"};
case (_lat<-64): {"D"};
@ -75,6 +77,16 @@ _band = switch (true) do {
case (_lat>8): {"P"};
case (_lat>=0): {"N"};
};
*/
_zone = 1 + (floor ((_long + 180) / 6));
_band = "Z";
if (_lat <= -80) then {
_band = "A";
} else {
if (_lat < 84) then {
_band = "CDEFGHJKLMNPQRSTUVWXX" select [(floor ((_lat / 8) + 10)), 1];
};
};
if (_map == "VR") then {_zone = 0; _band = "RV";};
_GZD = format ["%1%2",_zone,_band];
@ -146,6 +158,6 @@ _grid100km = _letterE+_letterN;
TRACE_1("",_grid100km);
if (_map == worldName) then {
GVAR(MGRS_data) = [_GZD,_grid100km];
GVAR(MGRS_data) = [_GZD,_grid100km,_GZD+_grid100km];
};
[_GZD,_grid100km]
[_GZD,_grid100km,_GZD+_grid100km]

View File

@ -54,22 +54,5 @@ GVAR(rangeFinderPositionASL) = [];
GVAR(mapAltitude) = getNumber (configFile >> "CfgWorlds" >> worldName >> "elevationOffset");
private ["_worldMapLong", "_worldMapLat", "_zone", "_band", "_squareID"];
//Calculate the map's MGRS:
_worldMapLong = getNumber (configFile >> "CfgWorlds" >> worldName >> "longitude");
_worldMapLat = getNumber (configFile >> "CfgWorlds" >> worldName >> "latitude");
//Pull UTM grid from world's long/lat
_zone = 1 + (floor ((_worldMapLong + 180) / 6));
_band = "Z";
if (_worldMapLat <= -80) then {
_band = "A";
} else {
if (_worldMapLat < 84) then {
_band = "CDEFGHJKLMNPQRSTUVWXX" select [(floor ((_worldMapLat / 8) + 10)), 1];
};
};
//calculating square ID from long/lat is a pain in the ass, just fake it unless someone wants to actualy do this
_squareID = if ((count worldName) > 2) then {toUpper(worldName select [0,2])} else {"XG"};
GVAR(mgrsGridZoneDesignator) = format ["%1%2 %3", _zone, _band, _squareID];
GVAR(mgrsGridZoneDesignator) = format ["%1 %2",EGVAR(map,MGRS_data) select 0, EGVAR(map,MGRS_data) select 1];