/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
Ext.namespace("Inspire.options");

/*
 * This file defines the layout for the entire app.
 * We could define a single huge Heron.layout tree, but for clarity we define
 * specific options (Inspire.options) separate first and then assign them to fields in the Heron.layout tree.
 */
OpenLayers.Util.onImageLoadErrorColor = "transparent";
OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";

Inspire.options.locations = {
	TILBURG: '5.0850, 51.5639',
	LIMBURG: '5.891, 50.775',
	AMERSFOORT: '5.2861, 52.1613',
	LOSSER: '6.84, 52.30'

};

Inspire.options.urls = {
	GS2_INSPIRE_WMS :  'http://kademo.nl/gs2/inspire/wms?',
	GS2_KADASTER_WMS :  'http://gis.kademo.nl/gs2/wms?',
	TILECACHE :  'http://gis.kademo.nl/cgi-bin/tilecache.cgi?',
	INTERACTIVE_INSTRUMENTS_WMS: 'http://services.interactive-instruments.de/exm-ni/cgi-bin/xs01-wms?',
	WHEREGROUP_WMS: 'http://osm.wheregroup.com/cgi-bin/osm_basic.xml?'
};

/** All MapPanel options. */
Inspire.options.map = {
	settings : {
		allOverlays : true,
		projection: 'EPSG:4258',
		units: 'dd',
		resolutions: [0.017929030859375, 0.0089645154296875001, 0.0044822577148437501, 0.002241128857421875, 0.0011205644287109375, 0.00056028221435546876, 0.00028014110717773438, 0.00014007055358886719, 7.0035276794433595e-05, 3.5017638397216797e-05, 1.7508819198608399e-05, 8.7544095993041994e-06, 4.3772047996520997e-06, 2.1886023998260498e-06, 1.0943011999130249e-06, 5.4715059995651246e-07, 2.7357529997825623e-07, 1.3678764998912812e-07, 6.8393824994564058e-08, 3.4196912497282029e-08], //[860.160, 430.080, 215.040, 107.520, 53.760, 26.880, 13.440, 6.720, 3.360, 1.680, 0.840, 0.420, 0.210, 0.105, 0.0525],
		maxExtent: '2.7984656, 50.6264231, 7.3882975, 53.9511147',
		center: Inspire.options.locations.LOSSER,
		xy_precision: 6,
		zoom: 4,
		theme: null
	},

	layers: [

		new OpenLayers.Layer.WMS("Topo Raster",
				Inspire.options.urls.GS2_KADASTER_WMS,
				{layers: "top_raster", format: "image/jpeg", transparent: false, version: '1.3.0'},
				{singleTile: true,  isBaseLayer: false,   visibility: false, noLegend: true, yx: {'EPSG:4258': true}}
		),

		/*    wheregroupOSM: new OpenLayers.Layer.WMS(
		 "OpenStreetMapEU",
		 Inspire.options.urls.WHEREGROUP_WMS,
		 {layers: 'OSM_basic', format: 'image/png', transparent: false, version: '1.3.0', CRS: 'EPSG:4326'},
		 {singleTile: true, opacity: 0.2, isBaseLayer: false, visibility: false, attribution: "Data CC-By-SA by <a href='http://openstreetmap.org/'>OpenStreetMap</a>", noLegend: true, yx: {'EPSG:4258': true}}
		 ), */

		new OpenLayers.Layer.WMS(
				"OpenStreetMapNL",
				Inspire.options.urls.TILECACHE,
				{layers: "osm_4258", format: "image/png", transparent: false, bgcolor: "0x99b3cc"},
				{singleTile: false, isBaseLayer: false, visibility: true, attribution: "Data CC-By-SA by <a href='http://openstreetmap.org/'>OpenStreetMap</a>", noLegend: true}
		),



		new OpenLayers.Layer.WMS("AD.Address",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "AD.Address", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),

		// START "Official INSPIRE Layers" (with appropriate Layer Naming)
		new OpenLayers.Layer.WMS("AU.AdministrativeUnit",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "AU.AdministrativeUnit", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),

		new OpenLayers.Layer.WMS("AU.AdministrativeUnit.Order1",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "AU.AdministrativeUnit.Order1", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),

		new OpenLayers.Layer.WMS("AU.AdministrativeUnit.Order2",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "AU.AdministrativeUnit.Order2", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),

		new OpenLayers.Layer.WMS("AU.AdministrativeUnit.Order3",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "AU.AdministrativeUnit.Order3", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),

		new OpenLayers.Layer.WMS(
				"ExM.AdministrativeUnit.Lower.Saxony",
				Inspire.options.urls.INTERACTIVE_INSTRUMENTS_WMS,
				{layers: 'AU.AdministrativeUnit', format: 'image/png', transparent: true, version: '1.3.0', exceptions: ''},
				{singleTile: true, opacity: 0.7, visibility: false, alpha:true, yx: {'EPSG:4258': true}}
		),

		new OpenLayers.Layer.WMS("CP.CadastralParcel",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "CP.CadastralParcel", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),


		new OpenLayers.Layer.WMS("GN.NamedPlace",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "GN.NamedPlace", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),


		new OpenLayers.Layer.WMS("GN.NamedPlace.FuncArea",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "gn_functioneel_gebied", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),

		new OpenLayers.Layer.WMS("GN.NamedPlace.GeoArea",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "inspire:gn_geografisch_gebied", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),


		new OpenLayers.Layer.WMS("GN.NamedPlace.Elements",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "inspire:gn_inrichtings_element", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),


		new OpenLayers.Layer.WMS("GN.NamedPlace.RoadPoint",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "inspire:gn_wegdeel_punt", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),


		new OpenLayers.Layer.WMS("HY.Watercourse",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "HY.Watercourse", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),


		new OpenLayers.Layer.WMS("HY.StandingWater",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "HY.StandingWater", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),

		new OpenLayers.Layer.WMS("TN.RoadTransportNetwork.RoadLink",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "TN.RoadTransportNetwork.RoadLink", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),

		new OpenLayers.Layer.WMS("TN.RoadTransportNetwork.RoadArea",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "TN.RoadTransportNetwork.RoadArea", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),

		new OpenLayers.Layer.WMS("TN.RailTransportNetwork.RailwayLink",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "TN.RailTransportNetwork.RailwayLink", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),

		// END "Official INSPIRE Layers" (with appropriate Layer Naming)

		new OpenLayers.Layer.WMS("INSPIRE Test Parcels",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "inspire_test:cp_parcel", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),

		new OpenLayers.Layer.WMS("INSPIRE percelen28992",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "inspire_test:percelen28992", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		),

		new OpenLayers.Layer.WMS("INSPIRE percelen4258",
				Inspire.options.urls.GS2_INSPIRE_WMS,
				{layers: "inspire_test:percelen4258", format: "image/png", transparent: true, version: '1.3.0'},
				{isBaseLayer: false, singleTile: true,  visibility: false, alpha:true
					,featureInfoFormat: "application/vnd.ogc.gml", yx: {'EPSG:4258': true}}
		)
	],

	toolbar : [
		{type: "featureinfo", options: {max_features: 20}},
		{type: "-"} ,
		{type: "pan"},
		{type: "zoomin"},
		{type: "zoomout"},
		{type: "zoomvisible"},
		{type: "-"} ,
		{type: "zoomprevious"},
		{type: "zoomnext"},
		{type: "-"},
		{type: "measurelength"},
		{type: "measurearea"},
		{type: "-"},
		{type: "search_nominatim",
			// Optional options, see NominatimSearchCombo.js
			options : {
				emptyText: 'Type an address or placename',
				// See http://open.mapquestapi.com/nominatim/
				url: 'http://open.mapquestapi.com/nominatim/v1/search?format=json&countrycodes=NL',
				zoom: 11
			}}
	]
};

/**
 * Describes the menu layout and links to content items.
 * This config object is included in the Layout config below.
 *
 */
Inspire.options.menuItems = [
	{
		id: 'hr-menu-bar',
		xtype: 'toolbar',
		floating: false,
		items:[
			{
				xtype: 'tbspacer',
				width: 240
			},
			{
				xtype: 'tbbutton',
				text: 'About',
				card: 'hr-content-main',
				page: 'home',
				handler: Heron.widgets.MenuHandler.onSelect
			},
			{
				xtype: 'tbspacer',
				width: 20
			},
			{
				xtype: 'tbbutton',
				text: 'Map',
				card: 'hr-geo-main',
				handler: Heron.widgets.MenuHandler.onSelect
			},
			{
				xtype: 'tbspacer',
				width: 20
			},
			{
				xtype: 'tbbutton',
				text: 'Documentation',
				card: 'hr-content-main',
				page: 'documentation',
				handler: Heron.widgets.MenuHandler.onSelect
			},
			{
				xtype: 'tbspacer',
				width: 20
			},
			{
				xtype: 'tbbutton',
				text: 'Demos',
				card: 'hr-content-main',
				page: 'demos',
				handler: Heron.widgets.MenuHandler.onSelect
			},
			{
				xtype: 'tbspacer',
				width: 20
			},
			{
				xtype: 'tbbutton',
				text: 'Development',
				card: 'hr-content-main',
				page: 'development',
				handler: Heron.widgets.MenuHandler.onSelect
			},
			{
				xtype: 'tbspacer',
				width: 20
			},
			{
				xtype: 'tbbutton',
				text: 'Contact',
				card: 'hr-content-main',
				page: 'contact',
				handler: Heron.widgets.MenuHandler.onSelect
			}
		]
	}
];

// Replace default layer browser DefaultConfig.js
// Pass our theme tree config as an option
Ext.namespace("Inspire.options.layertree");

Inspire.options.layertree.tree = [
	{
		text:'Base Layers', iconCls: "pictogramBackgroundTopography", children:
			[
				{nodeType: 'gx_layer', layer: 'Topo Raster', text: 'Topo Raster' },
				{nodeType: 'gx_layer', layer: 'OpenStreetMapNL', text: 'OpenStreetMap (NL)' }
			]
	},

	{
		text:'Addresses (AD)', iconCls: "pictogramAD", children:
			[
				{nodeType: 'gx_layer', layer: 'AD.Address', text: 'Addresses' }
			]
	},
	{
		text:'Administrative Units (AU)', iconCls: "pictogramAU", children:
			[
				{nodeType: 'gx_layer', layer: 'AU.AdministrativeUnit.Order1', text: 'AdministrativeUnit1 (country)' },
				{nodeType: 'gx_layer', layer: 'AU.AdministrativeUnit.Order2', text: 'AdministrativeUnit2 (provinces)' },
				{nodeType: 'gx_layer', layer: 'AU.AdministrativeUnit.Order3', text: 'AdministrativeUnit3 (municipalities)' },
				{nodeType: 'gx_layer', layer: 'AU.AdministrativeUnit', text: 'AdministrativeUnit (all)' },
				{nodeType: 'gx_layer', layer: 'ExM.AdministrativeUnit.Lower.Saxony', text: 'ExM.AdministrativeUnit (DE)' },
				{nodeType: "hr_multilayer", layers: "AU.AdministrativeUnit,ExM.AdministrativeUnit.Lower.Saxony", text: 'AdministrativeUnit (NL+DE)' }
			]
	},
	{
		text:'CadastralParcels (CP)', iconCls: "pictogramCP", children:
			[
				{nodeType: 'gx_layer', layer: 'CP.CadastralParcel', text: 'CadastralParcels' }
			]
	},
	{
		text:'Geographical Names (GN)', iconCls: "pictogramGN", children:
			[
				{nodeType: 'gx_layer', layer: 'GN.NamedPlace', text: 'NamedPlaces (all)' },
				{nodeType: 'gx_layer', layer: 'GN.NamedPlace.FuncArea', text: 'NamedPlaces (func. areas)' },
				{nodeType: 'gx_layer', layer: 'GN.NamedPlace.GeoArea', text: 'NamedPlaces (geogr. areas)' },
				{nodeType: 'gx_layer', layer: 'GN.NamedPlace.Elements', text: 'NamedPlaces (inr elm)' },
				{nodeType: 'gx_layer', layer: 'GN.NamedPlace.RoadPoint', text: 'NamedPlaces (road point' }
			]
	},

	{
		text:'Hydrography (HY)', iconCls: "pictogramHY", children:
			[
				{nodeType: 'gx_layer', layer: 'HY.Watercourse', text: 'Watercourses' },
				{nodeType: 'gx_layer', layer: 'HY.StandingWater', text: 'StandingWater' },
				{nodeType: "hr_multilayer", layers: "HY.StandingWater,HY.Watercourse", text: 'Hydrography (all)' }
			]
	},

	{
		text:'TransportNetwork (TN)', iconCls: 'pictogramTN', children:
			[
				{nodeType: 'gx_layer', layer: 'TN.RoadTransportNetwork.RoadLink', text: 'RoadLinks' },
				{nodeType: 'gx_layer', layer: 'TN.RoadTransportNetwork.RoadArea', text: 'RoadAreas' },
				{nodeType: 'gx_layer', layer: 'TN.RailTransportNetwork.RailwayLink', text: 'RailwayLinks' },

				{nodeType: "hr_multilayer", layers: "TN.RoadTransportNetwork.RoadLink,TN.RoadTransportNetwork.RoadArea,TN.RailTransportNetwork.RailwayLink", text: 'RoadTransportNetwork (all)' }
			]
	}
];
/** Values for ContextBrowser (shortcuts to jump to specific layers/zoom/center on map. */
Inspire.options.contexts = [
	{
		id: 'tilburg',
		name: 'Show Addresses (Tilburg)',
		desc: 'Pan and zoom to show Addresses',
		layers: ['OpenStreetMapNL', 'AD.Address', 'CP.CadastralParcel'],
		x: 5.0850,
		y: 51.5639,
		zoom: 12
	},
	/*	{
	 id: 'limburg',
	 name: 'Show Cadastral Parcels (Limburg)',
	 desc: 'Pan and zoom to Cadastral Parcels',
	 layers: ['OpenStreetMap', 'INSPIRE Addresses', 'INSPIRE Parcels'],
	 x: 5.891,
	 y: 50.775,
	 zoom: 11
	 },    */
	{
		id: 'losser',
		name: 'Show Cadastral Parcels (Losser)',
		desc: 'Pan and zoom to Cadastral Parcels',
		layers: ['OpenStreetMapNL', 'CP.CadastralParcel'],
		x: 7.0377,
		y: 52.2633,
		zoom: 9
	}

];



