<commit_before>

var theSrdDocument = new srd_document;

// srd_init : called by SitRepDashboard when we are ready to 
// load initial values and the first 'screen' we will see :
// map, admin, or data.
function srd_init() {


// NEED TO GET RID OF THIS, values should be read in from srd_settings.xml
lat = 40.713;
lon = -73.998;
zoom = 13;
runFromServer = false;

// READ the srd_settings.xml file and load it into a dojo.data object.
dojo.xhrGet( {
	url	: "srd_settings.xml",
	handleAs: "xml",
	load: theSrdDocument.settings_init
} );


	
}
// END INIT FUNCTION

//srd_document CLASS 
function srd_document() {
	this.map = null;
	this.editTools = null;
	this.selectControl = null;
	this.drawControls = null;
	this.panel = null;
	this.theSelectedControl = null;

// SETTINGS WE SHOULD GET FROM srd_settings.xml
	this.srd_config = null;
	this.single_user = null;
	this.runFromServer = null;
	this.default_projection = null;
	this.start_lat = null;
	this.start_lon = null;
	this.start_zoom = null;
	
	

}

srd_document.prototype.settings_init = function(result) {
	theSrdDocument.srd_config = result;
//	this.start_lat = this.srd_config.get('start_lat');
	alert("TEST" + theSrdDocument.srd_config );
//		alert("TEST" + this.srd_config.name);


	theSrdDocument.map_init();
}


srd_document.prototype.map_init = function() {

map = new OpenLayers.Map("map", { 
	controls: [
		new OpenLayers.Control.Navigation(),
		new OpenLayers.Control.PanZoomBar(),
		new OpenLayers.Control.Attribution()
	],
	numZoomLevels: 6 
} );

OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
     name: "MapQuestOSM",
     //attribution: "Data CC-By-SA by <a href='http://openstreetmap.org/'>OpenStreetMap</a>",
     sphericalMercator: true,
     url: ' http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png',
/*     clone: function(obj) {
         if (obj == null) {
             obj = new OpenLayers.Layer.OSM(
             this.name, this.url, this.getOptions());
         }
         obj = OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]);
         return obj;
     },
*/
     CLASS_NAME: "OpenLayers.Layer.MapQuestOSM"
 });
 var mapquestosm = new OpenLayers.Layer.MapQuestOSM();




//Add the Google Maps Layer for debug purposes only (don't
//forget to get rid of script src from html file.)
//var gMapLayer = new OpenLayers.Layer.Google( "Google Maps", {numZoomLevels: 20} );

//Add OpenStreetMap Layer for debug purposes as well 
//var osmMapLayer = new OpenLayers.Layer.OSM();
var osmMapLayer = new OpenLayers.Layer.XYZ(
		"OSM",
		"http://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
		{
			attribution: "Data CC-By-SA by <a href='http://openstreetmap.org/'>OpenStreetMap</a>",
			sphericalMercator: true
 	}

);

var srMapLayer = new OpenLayers.Layer.OSM("SitRep GIS", 
//	"http://SitRepGIS.local:3001/osm_tiles/${z}/${x}/${y}.png",
	"http://SitRepGIS.local:3001/mq_tiles/${z}/${x}/${y}.png",
	{numZoomLevels: 19,
	 attribution: '<img src="img/SitRepLogo_Tiny.png" height="25" width="60">'
	 }
);

//Add style for precincts :
var pct_style_def =  new OpenLayers.Style( { 
	fillColor: "#0000FF",
	fillOpacity: 0.3,
	strokeColor: "#0000FF",
	strokeOpacity: 1,
	pointRadius: 6
} ); 
var pct_style_sel =  new OpenLayers.Style( { 
	fillColor: "#0011FF",
	fillOpacity: 0.3,
	strokeColor: "#0000FF",
	strokeOpacity: 1,
	pointRadius: 6
} ); 
var pct_styleMap = new OpenLayers.StyleMap( {"default":  pct_style_def, "select": pct_style_sel } );


// GET THE FULL DIR if we are running locally.
//var path = document.location.pathname;
//var dir = path.substring(path.indexOf('/', 1), path.lastIndexOf('/'));
//alert("DIR="+dir);

// Add the precinct boundaries as a gml file for now.
var policePcts;


if(runFromServer == false) {
	policePcts  = new OpenLayers.Layer.GML("Precinct Boundaries", "sr_data_public/PolicePctBoundaries.gml" ,{ isBaseLayer: false, projection: "EPSG:4326", visibility: false, styleMap: pct_styleMap  } );
} else {
	policePcts = new OpenLayers.Layer.Vector("Precinct Boundaries", {
		isBaseLayer: false,
		projection: "EPSG:4326",
		visibility: true,
		styleMap: pct_styleMap,
		strategies: [new OpenLayers.Strategy.Fixed()],
		projection: new OpenLayers.Projection("EPSG:4326"),
		protocol: new OpenLayers.Protocol.HTTP ( {
//		 	url: "file://"+dir+"/sr_data_public/PolicePctBoundaries.gml" ,
		 	url: "/Users/jreifer/Desktop/VBOX_SHARED/SitRepDashboard/sr_data_public/PolicePctBoundaries.gml" ,
			format: new OpenLayers.Format.GML()
		} ) 
	});
}

// Attach the base layer + the sr_data_public layer(s)
map.addLayers( [ mapquestosm, srMapLayer,  osmMapLayer]);
map.addLayers( [   policePcts ]);


var whiteboard = new srd_layer(map); 
whiteboard.loadData("WFST", "Whiteboard", "whiteboard" ,{ isBaseLayer: false, projection: "EPSG:4326", visibility: false} );





// Adding the Control for the Layer select 
map.addControl(new OpenLayers.Control.LayerSwitcher() );
//Adding control for tracking mouse movement 
map.addControl(new OpenLayers.Control.MousePosition( {  
	displayProjection: new OpenLayers.Projection("EPSG:4326")
} ) );



var sr_dynamicLayers = { 
	"Whiteboard": whiteboard
};

var sr_dynamicLayer_layer = new Array();
/*for(var layerName in sr_dynamicLayers ) {<commit_msg>Fixed the xml import functionality but we're going to change to import it directly as a dojo.data (store) instead of as a object  XMLDocument<commit_after>

var theSrdDocument = new srd_document;

theSrdDocument.start_zoom= 1000;

// srd_init : called by SitRepDashboard when we are ready to 
// load initial values and the first 'screen' we will see :
// map, admin, or data.
function srd_init() {


// NEED TO GET RID OF THIS, values should be read in from srd_settings.xml
lat = 40.713;
lon = -73.998;
zoom = 13;
runFromServer = false;

// READ the srd_settings.xml file and load it into a dojo.data object.
dojo.xhrGet( {
	url	: "srd_settings.xml",
	handleAs: "xml",
	load: function(result) {
		theSrdDocument.settings_init(result);
	},
	error: function(errorMessage) {
		theSrdDocument.errorOnLoad(errorMessage);
	}
} );


	
}
// END INIT FUNCTION

//srd_document CLASS 
function srd_document() {
	this.map = null;
	this.editTools = null;
	this.selectControl = null;
	this.drawControls = null;
	this.panel = null;
	this.theSelectedControl = null;

// SETTINGS WE SHOULD GET FROM srd_settings.xml
	this.srd_config = null;
	this.single_user = null;
	this.runFromServer = null;
	this.default_projection = null;
	this.start_lat = null;
	this.start_lon = null;
	this.start_zoom = null;
		

}


srd_document.prototype.errorOnLoad = function(errorMessage) {
	alert("Error Loading srd_setttings.xml : "+errorMessage);
	
}

srd_document.prototype.settings_init = function(result) {
	this.srd_config = result;
	this.start_lat = this.srd_config.getElementsByTagName('start_lat')[0].childNodes[0].nodeValue;
	this.start_lon = this.srd_config.getElementsByTagName('start_lon')[0].childNodes[0].nodeValue;
	alert("TEST" + this.start_lat);





	theSrdDocument.map_init();
}


srd_document.prototype.map_init = function() {

map = new OpenLayers.Map("map", { 
	controls: [
		new OpenLayers.Control.Navigation(),
		new OpenLayers.Control.PanZoomBar(),
		new OpenLayers.Control.Attribution()
	],
	numZoomLevels: 6 
} );

OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
     name: "MapQuestOSM",
     //attribution: "Data CC-By-SA by <a href='http://openstreetmap.org/'>OpenStreetMap</a>",
     sphericalMercator: true,
     url: ' http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png',
/*     clone: function(obj) {
         if (obj == null) {
             obj = new OpenLayers.Layer.OSM(
             this.name, this.url, this.getOptions());
         }
         obj = OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]);
         return obj;
     },
*/
     CLASS_NAME: "OpenLayers.Layer.MapQuestOSM"
 });
 var mapquestosm = new OpenLayers.Layer.MapQuestOSM();




//Add the Google Maps Layer for debug purposes only (don't
//forget to get rid of script src from html file.)
//var gMapLayer = new OpenLayers.Layer.Google( "Google Maps", {numZoomLevels: 20} );

//Add OpenStreetMap Layer for debug purposes as well 
//var osmMapLayer = new OpenLayers.Layer.OSM();
var osmMapLayer = new OpenLayers.Layer.XYZ(
		"OSM",
		"http://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
		{
			attribution: "Data CC-By-SA by <a href='http://openstreetmap.org/'>OpenStreetMap</a>",
			sphericalMercator: true
 	}

);

var srMapLayer = new OpenLayers.Layer.OSM("SitRep GIS", 
//	"http://SitRepGIS.local:3001/osm_tiles/${z}/${x}/${y}.png",
	"http://SitRepGIS.local:3001/mq_tiles/${z}/${x}/${y}.png",
	{numZoomLevels: 19,
	 attribution: '<img src="img/SitRepLogo_Tiny.png" height="25" width="60">'
	 }
);

//Add style for precincts :
var pct_style_def =  new OpenLayers.Style( { 
	fillColor: "#0000FF",
	fillOpacity: 0.3,
	strokeColor: "#0000FF",
	strokeOpacity: 1,
	pointRadius: 6
} ); 
var pct_style_sel =  new OpenLayers.Style( { 
	fillColor: "#0011FF",
	fillOpacity: 0.3,
	strokeColor: "#0000FF",
	strokeOpacity: 1,
	pointRadius: 6
} ); 
var pct_styleMap = new OpenLayers.StyleMap( {"default":  pct_style_def, "select": pct_style_sel } );


// GET THE FULL DIR if we are running locally.
//var path = document.location.pathname;
//var dir = path.substring(path.indexOf('/', 1), path.lastIndexOf('/'));
//alert("DIR="+dir);

// Add the precinct boundaries as a gml file for now.
var policePcts;


if(runFromServer == false) {
	policePcts  = new OpenLayers.Layer.GML("Precinct Boundaries", "sr_data_public/PolicePctBoundaries.gml" ,{ isBaseLayer: false, projection: "EPSG:4326", visibility: false, styleMap: pct_styleMap  } );
} else {
	policePcts = new OpenLayers.Layer.Vector("Precinct Boundaries", {
		isBaseLayer: false,
		projection: "EPSG:4326",
		visibility: true,
		styleMap: pct_styleMap,
		strategies: [new OpenLayers.Strategy.Fixed()],
		projection: new OpenLayers.Projection("EPSG:4326"),
		protocol: new OpenLayers.Protocol.HTTP ( {
//		 	url: "file://"+dir+"/sr_data_public/PolicePctBoundaries.gml" ,
		 	url: "/Users/jreifer/Desktop/VBOX_SHARED/SitRepDashboard/sr_data_public/PolicePctBoundaries.gml" ,
			format: new OpenLayers.Format.GML()
		} ) 
	});
}

// Attach the base layer + the sr_data_public layer(s)
map.addLayers( [ srMapLayer,  osmMapLayer, mapquestosm ]);
map.addLayers( [   policePcts ]);


var whiteboard = new srd_layer(map); 
whiteboard.loadData("WFST", "Whiteboard", "whiteboard" ,{ isBaseLayer: false, projection: "EPSG:4326", visibility: false} );





// Adding the Control for the Layer select 
map.addControl(new OpenLayers.Control.LayerSwitcher() );
//Adding control for tracking mouse movement 
map.addControl(new OpenLayers.Control.MousePosition( {  
	displayProjection: new OpenLayers.Projection("EPSG:4326")
} ) );



var sr_dynamicLayers = { 
	"Whiteboard": whiteboard
};

var sr_dynamicLayer_layer = new Array();
/*for(var layerName in sr_dynamicLayers ) {
{'fraction_non_alphanumeric': 0.14591332967635764, 'fraction_numerical': 0.014993600292558055, 'mean_word_length': 4.12125468164794, 'pattern_counts': {'":': 6, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1139762', 'n_tokens_mistral': 4346, 'n_tokens_neox': 3970, 'n_words': 853}