//
// time: Fri Oct 23 15:17:34 1998
//
// version: 3.1.2 (format), 4.1.1 (DX Beta)
//
//
// Begin MDF
// MODULE MOSFromLongLat
// CATEGORY Macros
// DESCRIPTION Map long lat positions into MapOnStates coords
// INPUT data; field; (none); field to be transformed by a Azimuthal Equidistant projection
// OUTPUT AzEq; field; field transformed by Azimuthal Equidistant projection
// End MDF
//
// comment: Maps field containing long/lat positions into the MapOnStates coord. system. 
// comment: 
// comment:  (C) COPYRIGHT International Business Machines Corp. 1996.
// comment:  All Rights Reserved.
// comment:  Licensed Materials - Property of IBM
// comment: 
// comment:  Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the software without specific prior written permission.
// comment: 
// comment: INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THE SOFTWARE, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  IBM DOES NOT WARRANT AGAINST THE INFRINGMENT OF PATENTS, COPYRIGHT OR ANY OTHER INTELLECTUAL PROPERTY RIGHTS OF OTHERS.  IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, IS WITH YOU.
// workspace: width = 546, height = 635
// layout: snap = 0, width = 50, height = 50, align = CC
//
macro MOSFromLongLat(
 data
) -> (
 AzEq
) {
    // 
    // node Input[1]: x = 80, y = 6, inputs = 0, label = Input
    // parameter: position = 1, name = 'data', value = ' ', descriptive = 0, description = 'field to be transformed by a Azimuthal Equidistant projection', required = 1, visible = 1
    //
MOSFromLongLat_Input_1_out_1 = data;
    // 
    // node Mark[1]: x = 61, y = 86, inputs = 2, label = Mark (positions of input field)
    // input[2]: defaulting = 0, visible = 1, type = 32, value = "positions"
    //
MOSFromLongLat_Mark_1_out_1[cache: 0] = 
    Mark(
    MOSFromLongLat_Input_1_out_1,
    "positions"
    ) [instance: 1, cache: 1];
    // 
    // node Compute[3]: x = 167, y = 179, inputs = 3, label = Compute
    // input[1]: defaulting = 0, visible = 0, type = 32, value = "[$0.y, $0.x, 0.0]"
    // expression: value = [point.y, point.x, 0.0]
    // name[2]: value = point
    // name[3]: value = b
    //
MOSFromLongLat_Compute_3_out_1 = 
    Compute(
    "[$0.y, $0.x, 0.0]",
    MOSFromLongLat_Mark_1_out_1,
    NULL
    ) [instance: 3, cache: 1];
    // 
    // node Compute[5]: x = 233, y = 101, inputs = 1, label = Compute
    // input[1]: defaulting = 0, visible = 0, type = 32, value = "3.1415926535898/180."
    // expression: value = 3.1415926535898/180.
    //
MOSFromLongLat_Compute_5_out_1[cache: 2] = 
    Compute(
    "3.1415926535898/180."
    ) [instance: 5, cache: 1];
    // 
    // node Compute[12]: x = 366, y = 112, inputs = 3, label = Compute
    // input[1]: defaulting = 0, visible = 0, type = 32, value = "37.0"
    // expression: value = 37.0
    // name[2]: value = a
    // name[3]: value = b
    //
MOSFromLongLat_Compute_12_out_1[cache: 2] = 
    Compute(
    "37.0",
    NULL,
    NULL
    ) [instance: 12, cache: 1];
    // 
    // node Compute[13]: x = 488, y = 135, inputs = 3, label = Compute
    // input[1]: defaulting = 0, visible = 0, type = 32, value = "-98.0"
    // expression: value = -98.0
    // name[2]: value = a
    // name[3]: value = b
    //
MOSFromLongLat_Compute_13_out_1[cache: 2] = 
    Compute(
    "-98.0",
    NULL,
    NULL
    ) [instance: 13, cache: 1];
    // 
    // node Compute[4]: x = 339, y = 232, inputs = 5, label = Compute
    // input[1]: defaulting = 0, visible = 0, type = 32, value = "acos(sin($2*$1)*sin($0.x*$1) + cos($2*$1)*cos($0.x*$1)*cos(($0.y-$3)*$1) ) + 0.00001"
    // expression: value = acos(sin(lat0*deg2rad)*sin(point.x*deg2rad) + cos(lat0*deg2rad)*cos(point.x*deg2rad)*cos((point.y-lon0)*deg2rad) ) + 0.00001
    // name[2]: value = point
    // name[3]: value = deg2rad
    // name[4]: value = lat0
    // name[5]: value = lon0
    //
MOSFromLongLat_Compute_4_out_1 = 
    Compute(
    "acos(sin($2*$1)*sin($0.x*$1) + cos($2*$1)*cos($0.x*$1)*cos(($0.y-$3)*$1) ) + 0.00001",
    MOSFromLongLat_Compute_3_out_1,
    MOSFromLongLat_Compute_5_out_1,
    MOSFromLongLat_Compute_12_out_1,
    MOSFromLongLat_Compute_13_out_1
    ) [instance: 4, cache: 1];
    // 
    // node Compute[1]: x = 350, y = 352, inputs = 6, label = Compute
    // input[1]: defaulting = 0, visible = 0, type = 32, value = "[63.6396103*($1/sin($1))*(cos($3*$2)*sin($0.x*$2)-sin($3*$2)*cos($0.x*$2)*cos(($0.y-$4)*$2)), 63.6396103*($1/sin($1))*sin(($0.y-$4)*$2)*cos($0.x*$2), $0.z]"
    // expression: value = [63.6396103*(psi/sin(psi))*(cos(lat0*deg2rad)*sin(point.x*deg2rad)-sin(lat0*deg2rad)*cos(point.x*deg2rad)*cos((point.y-lon0)*deg2rad)), 63.6396103*(psi/sin(psi))*sin((point.y-lon0)*deg2rad)*cos(point.x*deg2rad), point.z]
    // name[2]: value = point
    // name[3]: value = psi
    // name[4]: value = deg2rad
    // name[5]: value = lat0
    // name[6]: value = lon0
    //
MOSFromLongLat_Compute_1_out_1[cache: 0] = 
    Compute(
    "[63.6396103*($1/sin($1))*(cos($3*$2)*sin($0.x*$2)-sin($3*$2)*cos($0.x*$2)*cos(($0.y-$4)*$2)), 63.6396103*($1/sin($1))*sin(($0.y-$4)*$2)*cos($0.x*$2), $0.z]",
    MOSFromLongLat_Compute_3_out_1,
    MOSFromLongLat_Compute_4_out_1,
    MOSFromLongLat_Compute_5_out_1,
    MOSFromLongLat_Compute_12_out_1,
    MOSFromLongLat_Compute_13_out_1
    ) [instance: 1, cache: 1];
    // 
    // node Compute[11]: x = 305, y = 434, inputs = 3, label = Compute
    // input[1]: defaulting = 0, visible = 0, type = 32, value = "[$0.y, $0.x]"
    // expression: value = [a.y, a.x]
    // name[2]: value = a
    // name[3]: value = b
    //
MOSFromLongLat_Compute_11_out_1[cache: 0] = 
    Compute(
    "[$0.y, $0.x]",
    MOSFromLongLat_Compute_1_out_1,
    NULL
    ) [instance: 11, cache: 1];
    // 
    // node Unmark[1]: x = 244, y = 503, inputs = 2, label = Unmark
    // input[2]: defaulting = 0, visible = 1, type = 32, value = "positions"
    //
MOSFromLongLat_Unmark_1_out_1 = 
    Unmark(
    MOSFromLongLat_Compute_11_out_1,
    "positions"
    ) [instance: 1, cache: 1];
    // 
    // node Output[1]: x = 246, y = 575, inputs = 1, label = Output
    // parameter: position = 1, name = 'AzEq', value = ' ', descriptive = 0, description = 'field transformed by Azimuthal Equidistant projection', required = 0, visible = 1
    //
AzEq = MOSFromLongLat_Unmark_1_out_1;
// network: end of macro body
}
MOSFromLongLat_Input_1_out_1 = NULL;
MOSFromLongLat_Mark_1_out_1 = NULL;
MOSFromLongLat_Compute_3_out_1 = NULL;
MOSFromLongLat_Compute_5_out_1 = NULL;
MOSFromLongLat_Compute_12_out_1 = NULL;
MOSFromLongLat_Compute_13_out_1 = NULL;
MOSFromLongLat_Compute_4_out_1 = NULL;
MOSFromLongLat_Compute_1_out_1 = NULL;
MOSFromLongLat_Compute_11_out_1 = NULL;
MOSFromLongLat_Unmark_1_out_1 = NULL;
