// The DTileLayer holds a GTileLayer with information about rendering
// choropleth maps a la Ducky.
function DTileLayer(aJurisdictionType, aFieldName, aYear,
                   aMapping, aMinColour, aMaxColour, aMinValue, aMaxValue,
                   aNormalizer, aNormalizerYear, aNormalizerType)
{
  glayer = new GTileLayer(new GCopyrightCollection("Kaitlin Duck Sherwood"),3,15);
  glayer.getCopyright = function(a,b) { return {prefix:"Imagery: &#169; 2009", copyrightTexts:["K. Duck Sherwood"]}; }

/*
  this.getBaseUrl = function() {
    // return "http://localhost/repo/maps.webfoot.com/mapeteria2/choropleth.phpx";
    return "http://maps.webfoot.com/mapeteria2/choropleth.phpx";
  }
*/
  glayer.isPng = function() { return true;};
  glayer.getOpacity = function() { return 1.0; }

  glayer.getTileUrl = function(aPoint, aZoom) {
    var x=aPoint.x;
    var y=aPoint.y;
    var baseUrl = "http://maps.webfoot.com/mapeteria2/choropleth.phpx";
    // var baseUrl = "http://localhost/repo/maps.webfoot.com/mapeteria2/choropleth.phpx";
    var url = baseUrl+"?"+
              "x="+x+"&y="+y+"&zoom="+aZoom +
              "&polyType="+aJurisdictionType+
              "&table="+aJurisdictionType+"Attributes"+
              "&field="+aFieldName+
              "&year="+aYear+
              "&normalizer="+aNormalizer+
              "&normalizerYear="+aNormalizerYear+
              "&normalizerType="+aNormalizerType+
              "&mapping="+aMapping+
              "&minColour="+aMinColour+
              "&maxColour="+aMaxColour+
              "&minValue="+aMinValue+
              "&maxValue="+aMaxValue;
    return url;
  }


  return glayer;
}


// The DTileLayerOverlay holds a GTileLayerOverlay with information about 
// rendering choropleth maps a la Ducky.

function DTileLayerOverlay(aJurisdictionType, aFieldName, aYear,
                   aMapping, aMinColour, aMaxColour, aMinValue, aMaxValue,
                   aNormalizer, aNormalizerYear, aNormalizerType)
{

  return new GTileLayerOverlay(
     new DTileLayer(aJurisdictionType, aFieldName, aYear,
                   aMapping, aMinColour, aMaxColour, aMinValue, aMaxValue,
                   aNormalizer, aNormalizerYear, aNormalizerType));
}


// The DHybridMapType holds a GMapType with information about 
// rendering choropleth maps a la Ducky.

function DHybridMapType(aLabel, aJurisdictionType, aFieldName, aYear,
                   aMapping, aMinColour, aMaxColour, aMinValue, aMaxValue,
                   aNormalizer, aNormalizerYear, aNormalizerType)
{

  var layer = new DTileLayer(aJurisdictionType, aFieldName, aYear,
                   aMapping, aMinColour, aMaxColour, aMinValue, aMaxValue,
                   aNormalizer, aNormalizerYear, aNormalizerType);

  var hybridLayer = [layer,
       G_HYBRID_MAP.getTileLayers()[1] 
       // a reference to the upper tile layer of the hybrid map
    ];
  var hybrid = new GMapType(hybridLayer, G_SATELLITE_MAP.getProjection(), aLabel);
  // hybrid = new GMapType(hybridLayer, G_SATELLITE_MAP.getProjection(), aLabel, {maxResolution:15,minResolution:0,errorMessage:"Coudn't fetch tile..."});

  return hybrid;

}

