﻿
// ##########################################################
// ########## Shape Object: for GEO-RSS boundaries ##########
// ##########################################################

function Boundary()
{  
    this.VEShapeLayer = _geoRssLayer; // VEShapeLayer
    this.VEShape = null;
    this.Title = null;
	this.Description = null;
	this.GeoRssPolygon = null;
	this.shapeFillColor_Default = new VEColor( 0, 0, 255, 0.2 );	//blue
    this.shapeFillColor_Highlight = new VEColor( 255, 255, 0, .2 ); // yellow
    this.shapeLineColor_Default = new VEColor( 0, 0, 255, 0.5 );    //blue line
    this.shapeLineColor_Highlight = new VEColor( 185, 0, 0, 0.5 );    //red line
    this.shapeLineColor_Error = new VEColor( 185, 0, 0, 0.6 );		//black line
    this.geoRssLineWidth = 2;

}
Boundary.prototype.Populate = function(shapeItems)
{
    this.Title = shapeItems[0];
    this.Description = shapeItems[1];
    this.GeoRssPolygon = shapeItems[2];
}
Boundary.prototype.DisplayShapeArray = function(array) 
{
     this.VEShapeLayer.AddShape(array);
}
Boundary.prototype.GetShape = function()
{ 
        var shapeCoords = []; // array of alternating latitude and longitude values
        shapeCoords = this.GeoRssPolygon.split(" ");
        
        var latLongs = []; // array of VELatLong objects
        for(var shapeCoordsCounter = 0 ; shapeCoordsCounter < shapeCoords.length; shapeCoordsCounter++)
        {
            var latitude = shapeCoords[shapeCoordsCounter++];
            var longitude = shapeCoords[shapeCoordsCounter];
            var latLong = new VELatLong(parseFloat(latitude), parseFloat(longitude));
            latLongs.push(latLong);
        }
        
        this.VEShape = new VEShape(VEShapeType.Polygon, latLongs);
        this.VEShape.SetTitle(this.Title);   
        this.VEShape.SetDescription(this.Description);
        this.VEShape.SetFillColor(this.geoRssFillColor_Default);
        this.VEShape.SetLineColor(this.geoRssLineColor_Default);
        this.VEShape.SetLineWidth(this.geoRssLineWidth);
        this.VEShape.HideIcon();

    return this.VEShape;
}
