Skip to main content
Participating Frequently
February 16, 2018
Question

Will this help draw weather fronts with Photoshop and Javascript?

  • February 16, 2018
  • 7 replies
  • 3581 views

I am a meteorologist. I use Photoshop to help annotate maps. One thing I always wanted to do, but couldn't, was draw weather fronts.

Recently I've come across some javascript used by leafletjs to draw fronts. Does any of what I've seen get me closer to being able to draw a front with a path? I know Photoshop understands javascript, but not much more.

This is very esoteric. There are few of you who can help. So thanks in advance.

Leafletjs example with fronts:  Weather Prediction Center

Javascript code defining fronts:  front example.txt - Google Drive

This topic has been closed for replies.

7 replies

Participant
July 13, 2019

Hey guys,

I have made AI brush set with common types of fronts (pattern brushes), download link below for anyone who could use it. Cheers,

JANEK

AI Brushes file:

https://drive.google.com/open?id=1T9XgkeaQE72rOiidFXrxOsGbXDskmuG4

Chuck Uebele
Community Expert
Community Expert
February 27, 2018

A bit more refinement. Figured out the Highs and lows were not paths, but just letters, so changed that with the appropriate colors. Added a dashed line for the trofs also.

#target photoshop

//1035 px = 40 long  259 per 10 ----25.875 per 1 deg 12.9375 per 1/2 deg

//628 px = 20 lat  157 per 5------31px per 1 deg

//93px to left 130 long//156 to top 50 long

//left edge is 133.5942

//top edge is 55.0322

//right edge 58.91787

//botton edge  20.41935

var hanDist = .32

var strokeSize = 6

var wFile = new File('/c/AAA DATA/Photos/test/weather.js')

COLD = new Array()

TROF = new Array()

WARM = new Array()

STNRY = new Array()

OCFNT = new Array()

LOWS = new Array()

HIGHS = new Array()

$.evalFile (wFile, 50000)

var leftDeg = 133.5942

var topDeg = 55.0322

var longUnit = 25.875

var latUnit = 31

for(var i=0;i<COLD[0].length;i++){

    for(var j=0;j<COLD[0].length;j++){      

        COLD[0][1]= (leftDeg - Math.abs(COLD[0][1]))*longUnit

        COLD[0][0]= (topDeg- COLD[0][0])*latUnit

        }

    }

for(var i=0;i<TROF[0].length;i++){

    for(var j=0;j<TROF[0].length;j++){      

        TROF[0][1]= (leftDeg - Math.abs(TROF[0][1]))*longUnit

        TROF[0][0]= (topDeg- TROF[0][0])*latUnit

        }

    }

for(var i=0;i<WARM[0].length;i++){

    for(var j=0;j<WARM[0].length;j++){      

        WARM[0][1]= (leftDeg - Math.abs(WARM[0][1]))*longUnit

        WARM[0][0]= (topDeg- WARM[0][0])*latUnit

        }

    }

for(var i=0;i<OCFNT[0].length;i++){

    for(var j=0;j<OCFNT[0].length;j++){      

        OCFNT[0][1]= (leftDeg - Math.abs(OCFNT[0][1]))*longUnit

        OCFNT[0][0]= (topDeg- OCFNT[0][0])*latUnit

        }

    }

for(var i=0;i<STNRY[0].length;i++){

    for(var j=0;j<STNRY[0].length;j++){      

        STNRY[0][1]= (leftDeg - Math.abs(STNRY[0][1]))*longUnit

        STNRY[0][0]= (topDeg- STNRY[0][0])*latUnit

        }

    }

for(var i=0;i<LOWS.length;i++){

    for(var j=0;j<LOWS.length;j++){      

        LOWS[1]= (leftDeg - Math.abs(LOWS[1]))*longUnit

        LOWS[0]= (topDeg- LOWS[0])*latUnit

        }

    }

for(var i=0;i<HIGHS.length;i++){

    for(var j=0;j<HIGHS.length;j++){      

        HIGHS[1]= (leftDeg - Math.abs(HIGHS[1]))*longUnit

        HIGHS[0]= (topDeg- HIGHS[0])*latUnit

        }

    }

var doc = activeDocument;

var base = doc.activeLayer

var gpLayer

runLoop ('TROF', TROF[0],204,102,0);

runLoop ('COLD', COLD[0],0,0,255);

runLoop ('WARM', WARM[0],255,0,0);

runLoop ('STNRY', STNRY[0],255,255,0);

runLoop ('OCFNT', OCFNT[0],102,51,204);

mkHiLow ('LOWS', LOWS[0]);

mkHiLow ('HIGHS', HIGHS[0]);

function runLoop(fName,fArray,r,g,b){

    for (var i =0;i<fArray.length;i++){

        doc.activeLayer = base;

        createPath (fArray, fName + '-' +i);

        mkShape (strokeSize, r, g, b)

        if(fName=='TROF'){mkDash ()};

        doc.activeLayer.name =  fName +'-'+i +'-Shape' ;    

        }//end for loop

    }

function mkHiLow (fType, fArray, num){

    var pA = new Array();

    var frontFont = 'Arial-MT'

    var lowFcolor = new SolidColor();

        lowFcolor.rgb.red = 255;

        lowFcolor.rgb.green = 0;

        lowFcolor.rgb.blue = 0;  

       

    var hiFcolor = new SolidColor();

        hiFcolor.rgb.red = 0;

        hiFcolor.rgb.green = 0;

        hiFcolor.rgb.blue = 255;  

    for(var i=0;i<fArray.length;i++){

            var artLayerRef = doc.artLayers.add()

            artLayerRef.kind = LayerKind.TEXT;

            var textItemRef = artLayerRef.textItem;

            textItemRef.justification = Justification.CENTER;

            textItemRef.size = 50

            textItemRef.position = [fArray[1],fArray[0]+textItemRef.size*.3]          

           

            if(fType=='LOWS'){

                textItemRef.color = lowFcolor;

                textItemRef.contents = 'L';

                artLayerRef.name = 'LOWS-' + i;

                }

            else{

                textItemRef.color = hiFcolor;

                textItemRef.contents = 'H';

                artLayerRef.name = 'HIGHS-' + i;

                }   

            }//end loop

    }//end function

//======================================

//Make path section

//======================================

function getSlope(point1,point2){

    var pt1x = point1[0];

    var pt1y = point1[1];

    var pt2x = point2[0];

    var pt2y = point2[1];

   

    slope = (pt1y-pt2y)/(pt1x-pt2x)

    var result = new Array((pt1y-pt2y)/(pt1x-pt2x),pt1y-slope*pt1x)

    return result

   

    yInter = pt1y-slope*pt1x

    }

function startHandle(point1,point2){

    var pt1x = point1[0];

    var pt1y = point1[1];

    var pt2x = point2[0];

    var pt2y = point2[1];

   

    var len = Math.abs(pt1x-pt2x)*hanDist

    var x

    if(pt1x<pt2x){x=pt1x+len}

    else{x = pt1x-len}

    var mb= getSlope (point1, point2)

    var y = mb[0]*x + mb[1]

    return [x,y]

    }

function getAngle(p1,p2){

    return Math.atan2 (p2[1]-p1[1], p2[0]-p1[0])//*180/Math.PI;

    }

function lineLen(p1,p2){

    return Math.abs(Math.sqrt (Math.pow((p2[0]-p1[0]),2)+Math.pow((p2[1]-p1[1]),2)));

    }

function getPts(orig,ang,rad){

    var ptH = new Array();

    ptH[0]= orig[0] + rad * Math.cos (ang);

    ptH[1]= orig[1] + rad * Math.sin (ang);

    return ptH;

    }

function createPath(pA1, pName){

    var pA = new Array();

    for(var i=0;i<pA1.length;i++){//invert pt order otherwise y is first

        pA= new Array(pA1[1],pA1[0])

        }

    var lineA = new Array();

    var srcAng =''

    var refAng= ''

    var refAng2=''

    var lLen=''//length between current point and next point

    var lLen2=''//lenfth between current point and last point

    var ptHold1 = ''//for leading handle on next point

    var ptHold2 = ''//for leading handle on current point

    var ptHold3 = ''//for trailding point

    for(var i=0;i<pA.length;i++){

    //for(var i=0;i<pA.length-1;i++){

        if(i<pA.length-1){

            srcAng = getAngle (pA, pA[i+1]);//get angle between the two main points

            lLen = lineLen (pA, pA[i+1])*hanDist;

            }

        else{

            srcAng = getAngle (pA, pA[i-1]);//get angle between the two main points

            lLen = lineLen (pA, pA[i-1])*hanDist;           

            }

      

        //if(i>0&&i<pA.length-1){//Check to see if not an end point and get the angle of line from the origin to next point

       

        if(i==0 && pA.length>2){

            ptHold1 = getNextHandles (pA, i+1);

           

            refAng = getAngle (pA, ptHold1);

            ptHold2 = getPts (pA, refAng, lLen);

            ptHold3 = pA          

            }

       

        if(i>0 && i<pA.length-1){         

            lLen2 = lineLen (pA, pA[i-1])*hanDist;

            refAng = getAngle (pA[i-1], pA[i+1]);           

            refAng2 = getAngle (pA[i+1], pA[i-1]);

            ptHold2= getPts (pA, refAng, lLen2);

            ptHold3= getPts (pA, refAng2, lLen2);

            }

       

        if(i==pA.length-1){

            refAng = getAngle (pA, lineA[i-1].leftDirection);

            ptHold2 = pA;

            ptHold3 = getPts (pA, refAng, lLen)

            }

        lineA = new PathPointInfo;

        lineA.kind = PointKind.SMOOTHPOINT;

        lineA.anchor = pA;

        //-----Left is the leading handle

        lineA.leftDirection = ptHold2

        lineA.rightDirection = ptHold3              

        }

    var lineSubPathArray = new Array()

    lineSubPathArray[0] = new SubPathInfo()

    //lineSubPathArray[0].operation = ShapeOperation.SHAPEXOR

    lineSubPathArray[0].operation = ShapeOperation.SHAPEADD

    lineSubPathArray[0].closed = false

    lineSubPathArray[0].entireSubPath = lineA   

   

    var myPathItem = doc.pathItems.add(pName, lineSubPathArray)

    }

function getNextHandles(pA,num){

    var ang1 = getAngle (pA[num+1], pA[num-1]);

    var lLen = lineLen (pA[num-1], pA[num])*hanDist;

    var point1 = getPts (pA[num], ang1, lLen);

    return point1

    }

function mkShape(sWidth, red, green, blue){

    var idMk = charIDToTypeID( "Mk  " );

        var desc268 = new ActionDescriptor();

        var idnull = charIDToTypeID( "null" );

            var ref85 = new ActionReference();

            var idcontentLayer = stringIDToTypeID( "contentLayer" );

            ref85.putClass( idcontentLayer );

        desc268.putReference( idnull, ref85 );

        var idUsng = charIDToTypeID( "Usng" );

            var desc269 = new ActionDescriptor();

            var idType = charIDToTypeID( "Type" );

                var desc270 = new ActionDescriptor();

                var idClr = charIDToTypeID( "Clr " );

                    var desc271 = new ActionDescriptor();

                    var idRd = charIDToTypeID( "Rd  " );

                    desc271.putDouble( idRd, red );

                    var idGrn = charIDToTypeID( "Grn " );

                    desc271.putDouble( idGrn, green );

                    var idBl = charIDToTypeID( "Bl  " );

                    desc271.putDouble( idBl, blue );

                var idRGBC = charIDToTypeID( "RGBC" );

                desc270.putObject( idClr, idRGBC, desc271 );

            var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

            desc269.putObject( idType, idsolidColorLayer, desc270 );

            var idShp = charIDToTypeID( "Shp " );

                var desc272 = new ActionDescriptor();

                var idTrgp = charIDToTypeID( "Trgp" );

                var idPthK = charIDToTypeID( "PthK" );

                var idTrgp = charIDToTypeID( "Trgp" );

                desc272.putEnumerated( idTrgp, idPthK, idTrgp );

            var idpathClass = stringIDToTypeID( "pathClass" );

            desc269.putObject( idShp, idpathClass, desc272 );

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

                var desc273 = new ActionDescriptor();

                var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );

                desc273.putInteger( idstrokeStyleVersion, 2 );

                var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );

                desc273.putBoolean( idstrokeEnabled, true );

                var idfillEnabled = stringIDToTypeID( "fillEnabled" );

                desc273.putBoolean( idfillEnabled, false );

                var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc273.putUnitDouble( idstrokeStyleLineWidth, idPxl, sWidth );

                var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );

                var idPnt = charIDToTypeID( "#Pnt" );

                desc273.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 );

                var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );

                desc273.putDouble( idstrokeStyleMiterLimit, 100.000000 );

                var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

                var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

                var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" );

                desc273.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap );

                var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

                var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

                var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );

                desc273.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleAlignInside = stringIDToTypeID( "strokeStyleAlignCenter" );

                desc273.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignInside );

                var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );

                desc273.putBoolean( idstrokeStyleScaleLock, false );

                var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );

                desc273.putBoolean( idstrokeStyleStrokeAdjust, false );

                var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );

                    var list16 = new ActionList();

                desc273.putList( idstrokeStyleLineDashSet, list16 );

                var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );

                var idBlnM = charIDToTypeID( "BlnM" );

                var idNrml = charIDToTypeID( "Nrml" );

                desc273.putEnumerated( idstrokeStyleBlendMode, idBlnM, idNrml );

                var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );

                var idPrc = charIDToTypeID( "#Prc" );

                desc273.putUnitDouble( idstrokeStyleOpacity, idPrc, 100.000000 );

                var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );

                    var desc274 = new ActionDescriptor();

                    var idClr = charIDToTypeID( "Clr " );

                        var desc275 = new ActionDescriptor();

                        var idRd = charIDToTypeID( "Rd  " );

                        desc275.putDouble( idRd, red );

                        var idGrn = charIDToTypeID( "Grn " );

                        desc275.putDouble( idGrn, green );

                        var idBl = charIDToTypeID( "Bl  " );

                        desc275.putDouble( idBl, blue );

                    var idRGBC = charIDToTypeID( "RGBC" );

                    desc274.putObject( idClr, idRGBC, desc275 );

                var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

                desc273.putObject( idstrokeStyleContent, idsolidColorLayer, desc274 );

                var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );

                desc273.putDouble( idstrokeStyleResolution, 72.000000 );

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

            desc269.putObject( idstrokeStyle, idstrokeStyle, desc273 );

        var idcontentLayer = stringIDToTypeID( "contentLayer" );

        desc268.putObject( idUsng, idcontentLayer, desc269 );

        var idLyrI = charIDToTypeID( "LyrI" );

        desc268.putInteger( idLyrI, 18 );

    executeAction( idMk, desc268, DialogModes.NO );

    }

function mkDash(){

       var idsetd = charIDToTypeID( "setd" );

        var desc4 = new ActionDescriptor();

        var idnull = charIDToTypeID( "null" );

            var ref1 = new ActionReference();

            var idcontentLayer = stringIDToTypeID( "contentLayer" );

            var idOrdn = charIDToTypeID( "Ordn" );

            var idTrgt = charIDToTypeID( "Trgt" );

            ref1.putEnumerated( idcontentLayer, idOrdn, idTrgt );

        desc4.putReference( idnull, ref1 );

        var idT = charIDToTypeID( "T   " );

            var desc5 = new ActionDescriptor();

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

                var desc6 = new ActionDescriptor();

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleAlignCenter = stringIDToTypeID( "strokeStyleAlignCenter" );

                desc6.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignCenter );

                var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );

                    var list1 = new ActionList();

                    var idNne = charIDToTypeID( "#Nne" );

                    list1.putUnitDouble( idNne, 6.000000 );

                    var idNne = charIDToTypeID( "#Nne" );

                    list1.putUnitDouble( idNne, 2.000000 );

                desc6.putList( idstrokeStyleLineDashSet, list1 );

                var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );

                desc6.putInteger( idstrokeStyleVersion, 2 );

                var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );

                desc6.putBoolean( idstrokeEnabled, true );

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

            desc5.putObject( idstrokeStyle, idstrokeStyle, desc6 );

        var idshapeStyle = stringIDToTypeID( "shapeStyle" );

        desc4.putObject( idT, idshapeStyle, desc5 );

    executeAction( idsetd, desc4, DialogModes.NO );

    }

Chuck Uebele
Community Expert
Community Expert
February 26, 2018

Modified the script to draw the paths and shapes, no dots now. I don't know about the high and low zones, those don't look right. Still need to add the symbols.

#target photoshop

//1035 px = 40 long  259 per 10 ----25.875 per 1 deg 12.9375 per 1/2 deg

//628 px = 20 lat  157 per 5------31px per 1 deg

//93px to left 130 long//156 to top 50 long

//left edge is 133.5942

//top edge is 55.0322

//right edge 58.91787

//botton edge  20.41935

var hanDist = .32

var strokeSize = 12

var wFile = new File('/c/AAA DATA/Photos/test/weather.js')

COLD = new Array()

TROF = new Array()

WARM = new Array()

STNRY = new Array()

OCFNT = new Array()

LOWS = new Array()

HIGHS = new Array()

$.evalFile (wFile, 50000)

var leftDeg = 133.5942

var topDeg = 55.0322

var longUnit = 25.875

var latUnit = 31

for(var i=0;i<COLD[0].length;i++){

    for(var j=0;j<COLD[0].length;j++){      

        COLD[0][1]= (leftDeg - Math.abs(COLD[0][1]))*longUnit

        COLD[0][0]= (topDeg- COLD[0][0])*latUnit

        }

    }

for(var i=0;i<TROF[0].length;i++){

    for(var j=0;j<TROF[0].length;j++){      

        TROF[0][1]= (leftDeg - Math.abs(TROF[0][1]))*longUnit

        TROF[0][0]= (topDeg- TROF[0][0])*latUnit

        }

    }

for(var i=0;i<WARM[0].length;i++){

    for(var j=0;j<WARM[0].length;j++){      

        WARM[0][1]= (leftDeg - Math.abs(WARM[0][1]))*longUnit

        WARM[0][0]= (topDeg- WARM[0][0])*latUnit

        }

    }

for(var i=0;i<OCFNT[0].length;i++){

    for(var j=0;j<OCFNT[0].length;j++){      

        OCFNT[0][1]= (leftDeg - Math.abs(OCFNT[0][1]))*longUnit

        OCFNT[0][0]= (topDeg- OCFNT[0][0])*latUnit

        }

    }

for(var i=0;i<STNRY[0].length;i++){

    for(var j=0;j<STNRY[0].length;j++){      

        STNRY[0][1]= (leftDeg - Math.abs(STNRY[0][1]))*longUnit

        STNRY[0][0]= (topDeg- STNRY[0][0])*latUnit

        }

    }

for(var i=0;i<LOWS.length;i++){

    for(var j=0;j<LOWS.length;j++){      

        LOWS[1]= (leftDeg - Math.abs(LOWS[1]))*longUnit

        LOWS[0]= (topDeg- LOWS[0])*latUnit

        }

    }

for(var i=0;i<HIGHS.length;i++){

    for(var j=0;j<HIGHS.length;j++){      

        HIGHS[1]= (leftDeg - Math.abs(HIGHS[1]))*longUnit

        HIGHS[0]= (topDeg- HIGHS[0])*latUnit

        }

    }

var doc = activeDocument;

var base = doc.activeLayer

var gpLayer

runLoop ('TORF', TROF[0],255,0,255);

runLoop ('COLD', COLD[0],0,0,255);

runLoop ('WARM', WARM[0],255,0,0);

runLoop ('STNRY', STNRY[0],255,255,0);

runLoop ('OCFNT', OCFNT[0],0,255,255);

runLoop ('LOWS', LOWS,0,255,0);

runLoop ('HIGHS', HIGHS,0,0,0);

function runLoop(fName,fArray,r,g,b){

    for (var i =0;i<fArray.length;i++){

        doc.activeLayer = base;

        createPath (fArray, fName + '-' +i);

        mkShape (strokeSize, r, g, b)

        doc.activeLayer.name =  fName +'-'+i +'-Shape' ;        

        }//end for loop

    }

//======================================

//Make path section

//======================================

function getSlope(point1,point2){

    var pt1x = point1[0];

    var pt1y = point1[1];

    var pt2x = point2[0];

    var pt2y = point2[1];

   

    slope = (pt1y-pt2y)/(pt1x-pt2x)

    var result = new Array((pt1y-pt2y)/(pt1x-pt2x),pt1y-slope*pt1x)

    return result

   

    yInter = pt1y-slope*pt1x

    }

function startHandle(point1,point2){

    var pt1x = point1[0];

    var pt1y = point1[1];

    var pt2x = point2[0];

    var pt2y = point2[1];

   

    var len = Math.abs(pt1x-pt2x)*hanDist

    var x

    if(pt1x<pt2x){x=pt1x+len}

    else{x = pt1x-len}

    var mb= getSlope (point1, point2)

    var y = mb[0]*x + mb[1]

    return [x,y]

    }

function getAngle(p1,p2){

    return Math.atan2 (p2[1]-p1[1], p2[0]-p1[0])//*180/Math.PI;

    }

function lineLen(p1,p2){

    return Math.abs(Math.sqrt (Math.pow((p2[0]-p1[0]),2)+Math.pow((p2[1]-p1[1]),2)));

    }

function getPts(orig,ang,rad){

    var ptH = new Array();

    ptH[0]= orig[0] + rad * Math.cos (ang);

    ptH[1]= orig[1] + rad * Math.sin (ang);

    return ptH;

    }

function createPath(pA1, pName){

    var pA = new Array();

    for(var i=0;i<pA1.length;i++){//invert pt order otherwise y is first

        pA= new Array(pA1[1],pA1[0])

        }

    var lineA = new Array();

    var srcAng =''

    var refAng= ''

    var refAng2=''

    var lLen=''//length between current point and next point

    var lLen2=''//lenfth between current point and last point

    var ptHold1 = ''//for leading handle on next point

    var ptHold2 = ''//for leading handle on current point

    var ptHold3 = ''//for trailding point

    for(var i=0;i<pA.length;i++){

    //for(var i=0;i<pA.length-1;i++){

        if(i<pA.length-1){

            srcAng = getAngle (pA, pA[i+1]);//get angle between the two main points

            lLen = lineLen (pA, pA[i+1])*hanDist;

            }

        else{

            srcAng = getAngle (pA, pA[i-1]);//get angle between the two main points

            lLen = lineLen (pA, pA[i-1])*hanDist;           

            }

      

        //if(i>0&&i<pA.length-1){//Check to see if not an end point and get the angle of line from the origin to next point

       

        if(i==0 && pA.length>2){

            ptHold1 = getNextHandles (pA, i+1);

           

            refAng = getAngle (pA, ptHold1);

            ptHold2 = getPts (pA, refAng, lLen);

            ptHold3 = pA          

            }

       

        if(i>0 && i<pA.length-1){         

            lLen2 = lineLen (pA, pA[i-1])*hanDist;

            refAng = getAngle (pA[i-1], pA[i+1]);           

            refAng2 = getAngle (pA[i+1], pA[i-1]);

            ptHold2= getPts (pA, refAng, lLen2);

            ptHold3= getPts (pA, refAng2, lLen2);

            }

       

        if(i==pA.length-1){

            refAng = getAngle (pA, lineA[i-1].leftDirection);

            ptHold2 = pA;

            ptHold3 = getPts (pA, refAng, lLen)

            }

        lineA = new PathPointInfo;

        lineA.kind = PointKind.SMOOTHPOINT;

        lineA.anchor = pA;

        //-----Left is the leading handle

        lineA.leftDirection = ptHold2

        lineA.rightDirection = ptHold3              

        }

    var lineSubPathArray = new Array()

    lineSubPathArray[0] = new SubPathInfo()

    //lineSubPathArray[0].operation = ShapeOperation.SHAPEXOR

    lineSubPathArray[0].operation = ShapeOperation.SHAPEADD

    lineSubPathArray[0].closed = false

    lineSubPathArray[0].entireSubPath = lineA   

   

    var myPathItem = doc.pathItems.add(pName, lineSubPathArray)

    }

function getNextHandles(pA,num){

    var ang1 = getAngle (pA[num+1], pA[num-1]);

    var lLen = lineLen (pA[num-1], pA[num])*hanDist;

    var point1 = getPts (pA[num], ang1, lLen);

    return point1

    }

function mkShape(sWidth, red, green, blue){

    var idMk = charIDToTypeID( "Mk  " );

        var desc268 = new ActionDescriptor();

        var idnull = charIDToTypeID( "null" );

            var ref85 = new ActionReference();

            var idcontentLayer = stringIDToTypeID( "contentLayer" );

            ref85.putClass( idcontentLayer );

        desc268.putReference( idnull, ref85 );

        var idUsng = charIDToTypeID( "Usng" );

            var desc269 = new ActionDescriptor();

            var idType = charIDToTypeID( "Type" );

                var desc270 = new ActionDescriptor();

                var idClr = charIDToTypeID( "Clr " );

                    var desc271 = new ActionDescriptor();

                    var idRd = charIDToTypeID( "Rd  " );

                    desc271.putDouble( idRd, red );

                    var idGrn = charIDToTypeID( "Grn " );

                    desc271.putDouble( idGrn, green );

                    var idBl = charIDToTypeID( "Bl  " );

                    desc271.putDouble( idBl, blue );

                var idRGBC = charIDToTypeID( "RGBC" );

                desc270.putObject( idClr, idRGBC, desc271 );

            var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

            desc269.putObject( idType, idsolidColorLayer, desc270 );

            var idShp = charIDToTypeID( "Shp " );

                var desc272 = new ActionDescriptor();

                var idTrgp = charIDToTypeID( "Trgp" );

                var idPthK = charIDToTypeID( "PthK" );

                var idTrgp = charIDToTypeID( "Trgp" );

                desc272.putEnumerated( idTrgp, idPthK, idTrgp );

            var idpathClass = stringIDToTypeID( "pathClass" );

            desc269.putObject( idShp, idpathClass, desc272 );

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

                var desc273 = new ActionDescriptor();

                var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );

                desc273.putInteger( idstrokeStyleVersion, 2 );

                var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );

                desc273.putBoolean( idstrokeEnabled, true );

                var idfillEnabled = stringIDToTypeID( "fillEnabled" );

                desc273.putBoolean( idfillEnabled, false );

                var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc273.putUnitDouble( idstrokeStyleLineWidth, idPxl, sWidth );

                var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );

                var idPnt = charIDToTypeID( "#Pnt" );

                desc273.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 );

                var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );

                desc273.putDouble( idstrokeStyleMiterLimit, 100.000000 );

                var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

                var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

                var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" );

                desc273.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap );

                var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

                var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

                var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );

                desc273.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleAlignInside = stringIDToTypeID( "strokeStyleAlignCenter" );

                desc273.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignInside );

                var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );

                desc273.putBoolean( idstrokeStyleScaleLock, false );

                var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );

                desc273.putBoolean( idstrokeStyleStrokeAdjust, false );

                var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );

                    var list16 = new ActionList();

                desc273.putList( idstrokeStyleLineDashSet, list16 );

                var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );

                var idBlnM = charIDToTypeID( "BlnM" );

                var idNrml = charIDToTypeID( "Nrml" );

                desc273.putEnumerated( idstrokeStyleBlendMode, idBlnM, idNrml );

                var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );

                var idPrc = charIDToTypeID( "#Prc" );

                desc273.putUnitDouble( idstrokeStyleOpacity, idPrc, 100.000000 );

                var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );

                    var desc274 = new ActionDescriptor();

                    var idClr = charIDToTypeID( "Clr " );

                        var desc275 = new ActionDescriptor();

                        var idRd = charIDToTypeID( "Rd  " );

                        desc275.putDouble( idRd, red );

                        var idGrn = charIDToTypeID( "Grn " );

                        desc275.putDouble( idGrn, green );

                        var idBl = charIDToTypeID( "Bl  " );

                        desc275.putDouble( idBl, blue );

                    var idRGBC = charIDToTypeID( "RGBC" );

                    desc274.putObject( idClr, idRGBC, desc275 );

                var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

                desc273.putObject( idstrokeStyleContent, idsolidColorLayer, desc274 );

                var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );

                desc273.putDouble( idstrokeStyleResolution, 72.000000 );

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

            desc269.putObject( idstrokeStyle, idstrokeStyle, desc273 );

        var idcontentLayer = stringIDToTypeID( "contentLayer" );

        desc268.putObject( idUsng, idcontentLayer, desc269 );

        var idLyrI = charIDToTypeID( "LyrI" );

        desc268.putInteger( idLyrI, 18 );

    executeAction( idMk, desc268, DialogModes.NO );

    }

Chuck Uebele
Community Expert
Community Expert
February 18, 2018

Yea, I made the script to put each front in a separate group.

Chuck Uebele
Community Expert
Community Expert
February 17, 2018

Playing around with your data. I'm not really sure how it's used, but looking at the data, it is a series of arrays for each type of front. I played with the cold front data. It seems to be a series of nine arrays with a series of coordinates in each of the 9 arrays. So I wrote a script that creates a group for each of the nine arrays and then plots a dot for each of the coordinates. I have not idea if this is correct, and to spread the dots out, I multiplied each x & y value by 10 and added 1500 to the y values, as they were negative values. So if you start with a 1000px X 1000px document with the unit values set to pixels, you can see how this works.

#target photoshop

var doc = activeDocument;

var base = doc.activeLayer

var COLD = new Array();

COLD.push([[[49.7, -64.5], [48.4, -65.4], [46.2, -68.1], [44.3, -72.2], [42.1, -77.8]], [[31.2, -104.6], [30.8, -106.6], [30.7, -109.4], [31.4, -111.8], [32.6, -113.5]], [[33.7, -94.4], [32.7, -96.3], [32.1, -98.3], [31.5, -100.4], [31.2, -101.8]], [[43.4, -68.8], [42.1, -70.7], [40.9, -74.1], [39.9, -76.0], [38.8, -79.3], [38.1, -83.9], [37.0, -86.9], [36.2, -89.3], [35.6, -90.8]], [[46.2, -56.3], [45.0, -56.8], [43.8, -59.0], [43.9, -61.7]], [[49.9, -128.9], [49.1, -130.9], [49.1, -133.1], [49.9, -137.3], [50.8, -140.4], [52.0, -143.6]], [[54.5, -112.9], [55.0, -117.4], [56.5, -121.3], [58.2, -125.5]], [[31.9, -102.8], [33.0, -105.0], [35.3, -106.3], [39.2, -105.6]], [[42.2, -77.7], [41.3, -79.8], [40.6, -82.8], [40.4, -85.0]]]);

for (var i =0;i<COLD[0].length;i++){

    doc.activeLayer = base;

    mkLayer ('COLD-'+i);

    doc.activeLayer.name = 'COLD ' + i;

    for (var j=0;j<COLD[0].length;j++){

       

        mkDot (COLD[0][0]*10 , COLD[0][1] *10+1500)

        }

    

    }

function mkDot(x,y){

    var idMk = charIDToTypeID( "Mk  " );

        var desc3 = new ActionDescriptor();

        var idnull = charIDToTypeID( "null" );

            var ref2 = new ActionReference();

            var idcontentLayer = stringIDToTypeID( "contentLayer" );

            ref2.putClass( idcontentLayer );

        desc3.putReference( idnull, ref2 );

        var idUsng = charIDToTypeID( "Usng" );

            var desc4 = new ActionDescriptor();

            var idType = charIDToTypeID( "Type" );

                var desc5 = new ActionDescriptor();

                var idClr = charIDToTypeID( "Clr " );

                    var desc6 = new ActionDescriptor();

                    var idRd = charIDToTypeID( "Rd  " );

                    desc6.putDouble( idRd, 0.000000 );

                    var idGrn = charIDToTypeID( "Grn " );

                    desc6.putDouble( idGrn, 0.000000 );

                    var idBl = charIDToTypeID( "Bl  " );

                    desc6.putDouble( idBl, 0.000000 );

                var idRGBC = charIDToTypeID( "RGBC" );

                desc5.putObject( idClr, idRGBC, desc6 );

            var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

            desc4.putObject( idType, idsolidColorLayer, desc5 );

            var idShp = charIDToTypeID( "Shp " );

                var desc7 = new ActionDescriptor();

                var idunitValueQuadVersion = stringIDToTypeID( "unitValueQuadVersion" );

                desc7.putInteger( idunitValueQuadVersion, 1 );

                var idTop = charIDToTypeID( "Top " );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc7.putUnitDouble( idTop, idPxl, y-5 );

                var idLeft = charIDToTypeID( "Left" );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc7.putUnitDouble( idLeft, idPxl, x-5 );

                var idBtom = charIDToTypeID( "Btom" );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc7.putUnitDouble( idBtom, idPxl, y+5 );

                var idRght = charIDToTypeID( "Rght" );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc7.putUnitDouble( idRght, idPxl, x+5 );

            var idElps = charIDToTypeID( "Elps" );

            desc4.putObject( idShp, idElps, desc7 );

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

                var desc8 = new ActionDescriptor();

                var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );

                desc8.putInteger( idstrokeStyleVersion, 2 );

                var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );

                desc8.putBoolean( idstrokeEnabled, false );

                var idfillEnabled = stringIDToTypeID( "fillEnabled" );

                desc8.putBoolean( idfillEnabled, true );

                var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc8.putUnitDouble( idstrokeStyleLineWidth, idPxl, 14.000000 );

                var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );

                var idPnt = charIDToTypeID( "#Pnt" );

                desc8.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 );

                var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );

                desc8.putDouble( idstrokeStyleMiterLimit, 100.000000 );

                var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

                var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

                var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" );

                desc8.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap );

                var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

                var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

                var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );

                desc8.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleAlignInside = stringIDToTypeID( "strokeStyleAlignInside" );

                desc8.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignInside );

                var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );

                desc8.putBoolean( idstrokeStyleScaleLock, false );

                var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );

                desc8.putBoolean( idstrokeStyleStrokeAdjust, false );

                var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );

                    var list1 = new ActionList();

                desc8.putList( idstrokeStyleLineDashSet, list1 );

                var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );

                var idBlnM = charIDToTypeID( "BlnM" );

                var idNrml = charIDToTypeID( "Nrml" );

                desc8.putEnumerated( idstrokeStyleBlendMode, idBlnM, idNrml );

                var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );

                var idPrc = charIDToTypeID( "#Prc" );

                desc8.putUnitDouble( idstrokeStyleOpacity, idPrc, 100.000000 );

                var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );

                    var desc9 = new ActionDescriptor();

                    var idClr = charIDToTypeID( "Clr " );

                        var desc10 = new ActionDescriptor();

                        var idRd = charIDToTypeID( "Rd  " );

                        desc10.putDouble( idRd, 0.000000 );

                        var idGrn = charIDToTypeID( "Grn " );

                        desc10.putDouble( idGrn, 0.000000 );

                        var idBl = charIDToTypeID( "Bl  " );

                        desc10.putDouble( idBl, 255.000000 );

                    var idRGBC = charIDToTypeID( "RGBC" );

                    desc9.putObject( idClr, idRGBC, desc10 );

                var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

                desc8.putObject( idstrokeStyleContent, idsolidColorLayer, desc9 );

                var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );

                desc8.putDouble( idstrokeStyleResolution, 72.000000 );

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

            desc4.putObject( idstrokeStyle, idstrokeStyle, desc8 );

        var idcontentLayer = stringIDToTypeID( "contentLayer" );

        desc3.putObject( idUsng, idcontentLayer, desc4 );

        var idLyrI = charIDToTypeID( "LyrI" );

        desc3.putInteger( idLyrI, 2 );

    executeAction( idMk, desc3, DialogModes.NO );   

    }

function mergeDown(){

    var idMrgtwo = charIDToTypeID( "Mrg2" );

        var desc12 = new ActionDescriptor();

executeAction( idMrgtwo, desc12, DialogModes.NO );   

    }

function mkLayer(name){

    var idMk = charIDToTypeID( "Mk  " );

        var desc2 = new ActionDescriptor();

        var idnull = charIDToTypeID( "null" );

            var ref1 = new ActionReference();

            var idlayerSection = stringIDToTypeID( "layerSection" );

            ref1.putClass( idlayerSection );

        desc2.putReference( idnull, ref1 );

        var idlayerSectionStart = stringIDToTypeID( "layerSectionStart" );

        desc2.putInteger( idlayerSectionStart, 3 );

        var idlayerSectionEnd = stringIDToTypeID( "layerSectionEnd" );

        desc2.putInteger( idlayerSectionEnd, 4 );

        var idNm = charIDToTypeID( "Nm  " );

        desc2.putString( idNm, name);

    executeAction( idMk, desc2, DialogModes.NO );

    }

Participating Frequently
February 17, 2018

It's going to take me a little while to absorb this.  Meanwhile here's how those points work...

COLD.push([[[49.7, -64.5], [48.4, -65.4], [46.2, -68.1], [44.3, -72.2], [42.1, -77.8]],

This cold front starts at 49.7N Latitude and -64.5W Longitude.  OK -- it really should be W or - not both,  but you get the idea.  So, this first point is around the Gulf of St. Lawrence in Canada, then into Maine and so forth.  Fronts are a little fluid.  These lines are never exact.  Each front runs to the first double closing brackets.

They use a fixed url to store this data, so http://www.wpc.ncep.noaa.gov/exper/nationalforecastchart/data/fronts92f.js  will always contain data corresponding to what's on the map.

Chuck, thanks again.

Chuck Uebele
Community Expert
Community Expert
February 17, 2018

Ok, so I did have the right idea that the set of coordinates were for o e front - each array with a set of coordinate arrays. Just need to figure out the plotting in relation to a Photoshop image and unit value.

Chuck Uebele
Community Expert
Community Expert
February 16, 2018

For a stationary front, you could draw both the warm and cold fronts then mask them:

Participating Frequently
February 16, 2018

Chuck - you are currently my favorite person on Earth.  I can't begin to thank you enough.  I've been looking to do this since I first started using Photoshop, over a decade ago.

I also had a chance last night to look at your pattern drawing app for Photoshop.  Thanks for making this contribution to the community.

I hope you don't mind, but I'll be back with questions later (surely).

Again, thank you.

Geoff

JJMack
Community Expert
Community Expert
February 16, 2018

That is a very elaborate dynamic web page the has a world map you can drag around zoom in and out and control weather overlays. The overlays only seem to be available north America.  If you are asking if Photoshop can create a web page like that the answer is no.  Photoshop may be used to create some of the  overlays the web page uses Shape with fills,  Text,  Paths Stroked.   A Photoshop script may be able to be written to read a file that has prepared weather information fot plotting weather front, storms areas etc and create the overlays  for the web page to use and save them for the web server to access.  Some of the plots may be a special weather symbol font would be like text on a path.

JJMack
Participating Frequently
February 16, 2018

First, thank you for your assistance.  Yes, the only thing I want to be able to do is draw fronts.  If you check Google over the years I've asked this question many times.  Sadly, the answer is no, or use Inkscape/Illustrator.

However, the fronts you see on the Weather Service site are produced using javascript (those are the descriptions in my file, the actual points are elsewhere in the code) and Photoshop speaks some javascript.

That last sentence is the extent of my knowledge.  But if it's possible to do, I'll do my best to figure it out.  This is a big deal for me.

Again, thanks.

Chuck Uebele
Community Expert
Community Expert
February 18, 2018

The good news is cold fronts are out of the north or west around 99% of the time.  I saw the cold front you drew.  There could be one that looks like that, but I've never seen it.  They all bow positively.

Warm fronts are mainly from the south and west.

Of course south of the equator it's all reversed and near the equator there are no fronts at all.


Okay, this script will only work with this map, as the points are adjusted for it.

Here's what I got plotting just the cold front.:

#target photoshop

//1035 px = 40 long  259 per 10 ----25.875 per 1 deg 12.9375 per 1/2 deg

//628 px = 20 lat  157 per 5------31px per 1 deg

//93px to left 130 long//156 to top 50 long

//left edge is 133.5942

//top edge is 55.0322

//right edge 58.91787

//botton edge  20.41935

var leftDeg = 133.5942

var topDeg = 55.0322

var longUnit = 25.875

var latUnit = 31

var doc = activeDocument;

var base = doc.activeLayer

var COLD = new Array();

COLD.push([[[49.7, -64.5], [48.4, -65.4], [46.2, -68.1], [44.3, -72.2], [42.1, -77.8]], [[31.2, -104.6], [30.8, -106.6], [30.7, -109.4], [31.4, -111.8], [32.6, -113.5]], [[33.7, -94.4], [32.7, -96.3], [32.1, -98.3], [31.5, -100.4], [31.2, -101.8]], [[43.4, -68.8], [42.1, -70.7], [40.9, -74.1], [39.9, -76.0], [38.8, -79.3], [38.1, -83.9], [37.0, -86.9], [36.2, -89.3], [35.6, -90.8]], [[46.2, -56.3], [45.0, -56.8], [43.8, -59.0], [43.9, -61.7]], [[49.9, -128.9], [49.1, -130.9], [49.1, -133.1], [49.9, -137.3], [50.8, -140.4], [52.0, -143.6]], [[54.5, -112.9], [55.0, -117.4], [56.5, -121.3], [58.2, -125.5]], [[31.9, -102.8], [33.0, -105.0], [35.3, -106.3], [39.2, -105.6]], [[42.2, -77.7], [41.3, -79.8], [40.6, -82.8], [40.4, -85.0]]]);

//$.writeln(COLD[0].length)

for (var i =0;i<COLD[0].length;i++){

    doc.activeLayer = base;

    mkLayer ('COLD-'+i);

    doc.activeLayer.name = 'COLD ' + i;

    for (var j=0;j<COLD[0].length;j++){

       

        mkDot (COLD[0][1] , COLD[0][0])

        }

    

    }

function mkDot(x1,y2){

    var x = (leftDeg - Math.abs(x1))*longUnit

    var y =(topDeg- y2)*latUnit

    var idMk = charIDToTypeID( "Mk  " );

        var desc3 = new ActionDescriptor();

        var idnull = charIDToTypeID( "null" );

            var ref2 = new ActionReference();

            var idcontentLayer = stringIDToTypeID( "contentLayer" );

            ref2.putClass( idcontentLayer );

        desc3.putReference( idnull, ref2 );

        var idUsng = charIDToTypeID( "Usng" );

            var desc4 = new ActionDescriptor();

            var idType = charIDToTypeID( "Type" );

                var desc5 = new ActionDescriptor();

                var idClr = charIDToTypeID( "Clr " );

                    var desc6 = new ActionDescriptor();

                    var idRd = charIDToTypeID( "Rd  " );

                    desc6.putDouble( idRd, 255.000000 );

                    var idGrn = charIDToTypeID( "Grn " );

                    desc6.putDouble( idGrn, 0.000000 );

                    var idBl = charIDToTypeID( "Bl  " );

                    desc6.putDouble( idBl, 255.000000 );

                var idRGBC = charIDToTypeID( "RGBC" );

                desc5.putObject( idClr, idRGBC, desc6 );

            var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

            desc4.putObject( idType, idsolidColorLayer, desc5 );

            var idShp = charIDToTypeID( "Shp " );

                var desc7 = new ActionDescriptor();

                var idunitValueQuadVersion = stringIDToTypeID( "unitValueQuadVersion" );

                desc7.putInteger( idunitValueQuadVersion, 1 );

                var idTop = charIDToTypeID( "Top " );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc7.putUnitDouble( idTop, idPxl, y-5 );

                var idLeft = charIDToTypeID( "Left" );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc7.putUnitDouble( idLeft, idPxl, x-5 );

                var idBtom = charIDToTypeID( "Btom" );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc7.putUnitDouble( idBtom, idPxl, y+5 );

                var idRght = charIDToTypeID( "Rght" );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc7.putUnitDouble( idRght, idPxl, x+5 );

            var idElps = charIDToTypeID( "Elps" );

            desc4.putObject( idShp, idElps, desc7 );

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

                var desc8 = new ActionDescriptor();

                var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );

                desc8.putInteger( idstrokeStyleVersion, 2 );

                var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );

                desc8.putBoolean( idstrokeEnabled, false );

                var idfillEnabled = stringIDToTypeID( "fillEnabled" );

                desc8.putBoolean( idfillEnabled, true );

                var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc8.putUnitDouble( idstrokeStyleLineWidth, idPxl, 14.000000 );

                var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );

                var idPnt = charIDToTypeID( "#Pnt" );

                desc8.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 );

                var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );

                desc8.putDouble( idstrokeStyleMiterLimit, 100.000000 );

                var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

                var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

                var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" );

                desc8.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap );

                var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

                var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

                var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );

                desc8.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleAlignInside = stringIDToTypeID( "strokeStyleAlignInside" );

                desc8.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignInside );

                var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );

                desc8.putBoolean( idstrokeStyleScaleLock, false );

                var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );

                desc8.putBoolean( idstrokeStyleStrokeAdjust, false );

                var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );

                    var list1 = new ActionList();

                desc8.putList( idstrokeStyleLineDashSet, list1 );

                var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );

                var idBlnM = charIDToTypeID( "BlnM" );

                var idNrml = charIDToTypeID( "Nrml" );

                desc8.putEnumerated( idstrokeStyleBlendMode, idBlnM, idNrml );

                var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );

                var idPrc = charIDToTypeID( "#Prc" );

                desc8.putUnitDouble( idstrokeStyleOpacity, idPrc, 100.000000 );

                var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );

                    var desc9 = new ActionDescriptor();

                    var idClr = charIDToTypeID( "Clr " );

                        var desc10 = new ActionDescriptor();

                        var idRd = charIDToTypeID( "Rd  " );

                        desc10.putDouble( idRd, 0.000000 );

                        var idGrn = charIDToTypeID( "Grn " );

                        desc10.putDouble( idGrn, 0.000000 );

                        var idBl = charIDToTypeID( "Bl  " );

                        desc10.putDouble( idBl, 255.000000 );

                    var idRGBC = charIDToTypeID( "RGBC" );

                    desc9.putObject( idClr, idRGBC, desc10 );

                var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

                desc8.putObject( idstrokeStyleContent, idsolidColorLayer, desc9 );

                var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );

                desc8.putDouble( idstrokeStyleResolution, 72.000000 );

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

            desc4.putObject( idstrokeStyle, idstrokeStyle, desc8 );

        var idcontentLayer = stringIDToTypeID( "contentLayer" );

        desc3.putObject( idUsng, idcontentLayer, desc4 );

        var idLyrI = charIDToTypeID( "LyrI" );

        desc3.putInteger( idLyrI, 2 );

    executeAction( idMk, desc3, DialogModes.NO );   

    }

function mergeDown(){

    var idMrgtwo = charIDToTypeID( "Mrg2" );

        var desc12 = new ActionDescriptor();

executeAction( idMrgtwo, desc12, DialogModes.NO );   

    }

function mkLayer(name){

    var idMk = charIDToTypeID( "Mk  " );

        var desc2 = new ActionDescriptor();

        var idnull = charIDToTypeID( "null" );

            var ref1 = new ActionReference();

            var idlayerSection = stringIDToTypeID( "layerSection" );

            ref1.putClass( idlayerSection );

        desc2.putReference( idnull, ref1 );

        var idlayerSectionStart = stringIDToTypeID( "layerSectionStart" );

        desc2.putInteger( idlayerSectionStart, 3 );

        var idlayerSectionEnd = stringIDToTypeID( "layerSectionEnd" );

        desc2.putInteger( idlayerSectionEnd, 4 );

        var idNm = charIDToTypeID( "Nm  " );

        desc2.putString( idNm, name);

    executeAction( idMk, desc2, DialogModes.NO );

    }