Pomóż nam przetłumaczyć lub ulepszyć tłumaczenie tej strony i zdobądź darmową licencję !
Użytkownik anonimowy  |  Zaloguj  |  Utwórz konto
Wiadomość w środku Mejoras

WMS

Odpowiedz 
#1 - 2009-11-30 09:27:47 Reporta abuso | PermaLink
txema
Fecha de registro: 2007-03-05
31 posts en todos los foros
WMS

Odpowiedz Zacytuj
Estimado Subgurim:

He dejado este mensaje en respuesta en Ayuda pero creo que está mejor en este foro de mejoras...

Existen ya bastantes ejemplos de Google Maps con WMS:

Te dejo dos para que les eches un vistazo:

http://georeferencias.wordpress.com/2006/08/22/mostrando-capas-wms-sobre-google-maps/
http://www.icc.es/web/content/es/prof/cartografia/geoserveis.html

Revisa el codigo fuente del ejemplo de esta página. Quizás le falten algunas funciones al control tan majo que estas desarrollando.

http://www.icc.es/web/content/es/prof/cartografia/gm_wms.html

Si el control incorporara esta funcionalidad ganaría muchísmo. Otra cosa es que luego todos los WMS te dejen extraer sus capas desde Internet.Desde programas en PC sí lo hacen.

Saludos


EDITADO 30/11/2009 19:18:52: Añadir más datos
Góra

Odpowiedzi
De en 15 Ir a página Siguientes >>
#2 - 2010-07-29 19:40:47 Reporta abuso | PermaLink
Txema
Fecha de registro: 2007-03-05
31 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
Estimado Subgurim:

Al final he encontrado un rato para trabajar en este tema y te diré que en principio la propiedad TileUrlFunction la lee y la asigna pero me encuentro con la siguiente dificultad:

 lUL = G_NORMAL_MAP.getProjection().fromPixelToLatLng(lULP, b, c)
 lLR = G_NORMAL_MAP.getProjection().fromPixelToLatLng(lLRP, b, c)

Creo que esta funcion no está incorporda en el control y es propia de GoogleMaps.

http://code.google.com/intl/es/apis/maps/documentation/javascript/v2/reference.html#GProjection


Un saludo y gracias
Txema
Góra

#3 - 2010-03-04 20:52:27 Reporta abuso | PermaLink
subgurim
Fecha de registro: 2006-10-18
1782 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
Txema ha dicho:
Creo que con lo que te he puesto estaríamos on para probar que funcione y habría que probarlo, por lo que quedo a tu disposción si lo estimas oportuno.

Saludos
Txema


Hola Txema,

creo que lo tengo casi... En la próxima versión, que subiré en un par de días (la 3.4), he añadido la propiedad: "tileUrlFunction" a la clase GTileLayer. Ahí es donde tienes que darle "CustomGetTileUrl"... y en teoría debería funcionar.
Por favor, estate atento a esto y dime si funciona ;)

Saludos.
Góra

#4 - 2010-02-13 12:56:19 Reporta abuso | PermaLink
Txema
Fecha de registro: 2007-03-05
31 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
Creo que con lo que te he puesto estaríamos on para probar que funcione y habría que probarlo, por lo que quedo a tu disposción si lo estimas oportuno.

Saludos
Txema

Góra

#5 - 2010-02-10 17:02:16 Reporta abuso | PermaLink
subgurim
Fecha de registro: 2006-10-18
1782 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
Ok,

Gracias!! todo lo que vayas encontrando puedes ponerlo aqui. Cuando comience con la nueva versión vendré a este post para leerlo todo y analizarlo en detalle.
Góra

#6 - 2010-02-05 19:39:58 Reporta abuso | PermaLink
txema
Fecha de registro: 2007-03-05
31 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
Sigo con el tema y extrayendo información. Mi manejo de Javascript es el que es y quizás diga alguna burradilla.

Estoy intentando pasar el ejemplo del ICC con el control y echo en falta algunas funciones que se recogen en la API. Los servidores WMS trabajan en Mercator y necesitan convertir sus datos.

Parte de la solución está en http://code.google.com/intl/es-US/apis/maps/documentation/reference.html#GProjection.fromPixelToLatLng


Paso a hacerte los comentarios de lo que he ido trabajando.

function initialize() {
 if (GBrowserIsCompatible()) {
  var map = new GMap2(document.getElementById("map_canvas"));
  map.setCenter(new GLatLng(41.5580, 1.5906), 7);  
  map.setUIToDefault();
  
  var license = "<a href='http://www.icc.cat'><strong>Institut Cartogr&agrave;fic de Catalunya</strong></a>";
  var copyright = new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)), 0, license);
  var copyrightCollection = new GCopyrightCollection("");
  copyrightCollection.addCopyright(copyright);
  var tileICC= new GTileLayer(copyrightCollection,1,17);

hasta aquí todo se trasvasa sin problemas...

Estos tres miembros no los aporta el constructor pero puede revolverse mediante variables


  tileICC.myFormat='image/png';

  tileICC.myLayers='mtc250m,';    

  tileICC.myBaseURL="http://shagrat.icc.es/lizardtech/iserv/ows?";

'aquí llama a la función sin pasarle parámetros pero al función los tiene y los usa

  tileICC.getTileUrl=CustomGetTileUrl;

'esto creo que se adapta sin grandes problemas.  

  var mapaICC = new GTileLayerOverlay(tileICC);  

  map.addOverlay(mapaICC);
  
  var layerICC=[tileICC,tileICC];
  
  var layer1=[G_NORMAL_MAP.getTileLayers()[0],G_NORMAL_MAP.getTileLayers()[0]];

  var custommap1 = new GMapType(layer1, G_NORMAL_MAP.getProjection(),"Mapa", G_NORMAL_MAP);
  var custommapICC = new GMapType(layerICC,G_NORMAL_MAP.getProjection(), "WMS ICC", G_SATELLITE_MAP);
  map.getMapTypes().length = 0;
  //map.addMapType(custommap1);
  map.addMapType(custommapICC);
  map.setMapType(custommapICC);
  map.clearOverlays();
 }
}

'Y esta es la función. myLayers toma el valor según el zoom


function CustomGetTileUrl(a,b,c) {     
 /*
 this.myLayers='mtc250m';
 if (b>12){
  this.myLayers='mtc50m';
 }
 if (b>14){
  this.myLayers='mtc10m';
 }
 if (b>16){
  this.myLayers='mtc5m';
 } 
 */
 
 this.myLayers='mtc250m,';
 if (b>12){
  this.myLayers='mtc50m,';
 }
 if (b>14){
  this.myLayers='mtc10m,';
 }
 if (b>16){
  this.myLayers='mtc5m,';
 }  
 
 this.myStyles="";
 
 var lULP = new GPoint(a.x*256,(a.y+1)*256);
 var lLRP = new GPoint((a.x+1)*256,a.y*256);
 

 'Aquí están las funciones de Mercator que se precisan y no están en el control.

 var lUL = G_NORMAL_MAP.getProjection().fromPixelToLatLng(lULP,b,c);
 var lLR = G_NORMAL_MAP.getProjection().fromPixelToLatLng(lLRP,b,c);
  
 var lBbox=lUL.x+","+lUL.y+","+lLR.x+","+lLR.y;
 

'conseguido esto creo que estaría operativo el tema de los WMS en el control.

var lSRS="EPSG:4326";
 var lURL=this.myBaseURL;
 lURL+="&REQUEST=GetMap";
 lURL+="&SERVICE=WMS";
 lURL+="&VERSION=1.1.1";
 lURL+="&LAYERS="+this.myLayers;
 lURL+="&STYLES="+this.myStyles;
 lURL+="&FORMAT="+this.myFormat;
 lURL+="&BGCOLOR=0xFFFFFF";
 lURL+="&TRANSPARENT=TRUE";
 lURL+="&SRS="+lSRS;
 lURL+="&BBOX="+lBbox;
 lURL+="&WIDTH=256";
 lURL+="&HEIGHT=256";
 lURL+="&reaspect=false";
 return lURL;
}

Ya me dirás como lo ves... y quizás lo mejor sería borrar de este post el resto de los códigos...

Góra

#7 - 2010-02-01 20:17:11 Reporta abuso | PermaLink
subgurim
Fecha de registro: 2006-10-18
1782 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
OK, gracias por el apunte.

Tomo nota!!
Góra

#8 - 2010-01-31 22:57:49 Reporta abuso | PermaLink
txema
Fecha de registro: 2007-03-05
31 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
Te paso otra url, pero como dices hacen referencia a jscript en una libreria

http://roadlessland.org/notes/wms-usgs-example.html

Yo estoy muy perdido, como verás, en este tema, pero quizás si pudieras poner un ejemplo del control con wms en la Galería de código... te lo agradeceríamos.

Saludos
Góra

#9 - 2009-12-31 08:34:06 Reporta abuso | PermaLink
subgurim
Fecha de registro: 2006-10-18
1782 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
Hola Txema,

Por lo que deduzco del código, gran parte de las cosas se pueden hacer con tilelayers, y para el resto puedes usar CustomJavascript y CustomInsideJavascript.

De todos modos seguiré estudiándolo para ver si es factible incorporarlo a este control.

Saludos.
Góra

#10 - 2009-12-29 19:30:49 Reporta abuso | PermaLink
txema
Fecha de registro: 2007-03-05
31 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
Yo tampoco estoy muy puesto en este tema pero en la primera url que te pase ponía:

// Create WMSSpec
* // need: wmsURL, gName, gShortName, wmsLayers, wmsStyles, wmsFormat, [wmsVersion], [wmsBgColor], [wmsSrs]
* var G_MAP_WMS_SPEC = createWMSSpec(WMS_URL_ROUTE, “MyWMS”, “MyWMS”, “routes”, “default”, “image/gif”, “1.0.0″);
*
* // Use WMSSpec to create transparent overlay on a standard Google MapSpec
* var G_MAP_WMS_OVERLAY_SPEC = createWMSOverlaySpec(G_SATELLITE_TYPE, G_MAP_WMS_SPEC, “MyOvWMS”, “MyOvWMS”);

Hace referencia a una libreria de javascript gmap
cuyo contenido es:

/*
 * Create GoogleMap WMS (transparent) layers on any GoogleMap.
 *
 * Just van den Broecke - just AT justobjects.nl - www.justobjects.nl - www.geoskating.com
 * version: $Id: gmap-wms.js,v 1.11 2008-12-16 11:19:26 just Exp $
 *
 * This (experimental) code can be downloaded from
 * http://www.geotracing.com/gt/script/gmap.js
 *
 * CREDITS
 * This code is based on and inspired by:
 * Brian Flood - http://www.spatialdatalogic.com/cs/blogs/brian_flood/archive/2005/07/11/39.aspx and
 * Kyle Mulka - http://blog.kylemulka.com/?p=287
 * I have merely merged the two approaches taken by each of these great minds !
 *
 * EXAMPLE
 *   // Fake WMS server to be used for overlaying map with transparent GIF
 *   // Use a real WMS server here.
 *   var WMS_URL_ROUTE='http://www.geoskating.com/gmap/route-wms.jsp?';
 *
 *   // Create WMSSpec
 *   // need: wmsURL, gName, gShortName, wmsLayers, wmsStyles, wmsFormat, [wmsVersion], [wmsBgColor], [wmsSrs]
 *   var G_MAP_WMS_SPEC = createWMSSpec(WMS_URL_ROUTE, "MyWMS", "MyWMS", "routes", "default", "image/gif", "1.0.0");
 *
 *   // Use WMSSpec to create transparent overlay on a standard Google MapSpec
 *   var G_MAP_WMS_OVERLAY_SPEC = createWMSOverlaySpec(G_SATELLITE_MAP, G_MAP_WMS_SPEC, "MyOvWMS", "MyOvWMS");
 *
 *   // Setup the map
 *   var map = new GMap2(document.getElementById("map"));
 *   // Create mapspecs array
 *     map.addMapType(G_NORMAL_MAP);
 *     map.addMapType(G_SATELLITE_MAP);
 *      map.addMapType(G_MAP_WMS_SPEC);
 *     map.addMapType(G_MAP_WMS_OVERLAY_SPEC);
 *   map.addControl(new GMapTypeControl());
 *   map.setCenter(new GLatLon(52.35, 4.9), 10, G_MAP_WMS_OVERLAY_SPEC);
 */



/*
 Call generic wms service for GoogleMaps v2
 John Deck, UC Berkeley
 Inspiration & Code from:
 Mike Williams http://www.econym.demon.co.uk/googlemaps2/ V2 Reference & custommap code
 Brian Flood http://www.spatialdatalogic.com/cs/blogs/brian_flood/archive/2005/07/11/39.aspx V1 WMS code
 Kyle Mulka http://blog.kylemulka.com/?p=287  V1 WMS code modifications
 http://search.cpan.org/src/RRWO/GPS-Lowrance-0.31/lib/Geo/Coordinates/MercatorMeters.pm
 */

var MAGIC_NUMBER = 6356752.3142;
var DEG2RAD = 0.0174532922519943;
var PI = 3.14159267;
function dd2MercMetersLng(p_lng) {
    return MAGIC_NUMBER * (p_lng * DEG2RAD);
}

function dd2MercMetersLat(p_lat) {
    if (p_lat >= 85) p_lat = 85;
    if (p_lat <= -85) p_lat = -85;
    return MAGIC_NUMBER * Math.log(Math.tan(((p_lat * DEG2RAD) + (PI / 2)) / 2));
}

var CustomGetTileUrl = function(a, b, c) {
    if (typeof(window['this.myMercZoomLevel']) == "undefined") this.myMercZoomLevel = 0;
    if (typeof(window['this.myStyles']) == "undefined") this.myStyles = "";
    var lULP = new GPoint(a.x * 256, (a.y + 1) * 256);
    var lLRP = new GPoint((a.x + 1) * 256, a.y * 256);
    var lUL = G_NORMAL_MAP.getProjection().fromPixelToLatLng(lULP, b, c);
    var lLR = G_NORMAL_MAP.getProjection().fromPixelToLatLng(lLRP, b, c);
    // switch between Mercator and DD if merczoomlevel is set
    if (this.myMercZoomLevel != 0 && map.getZoom() < this.myMercZoomLevel) {
        var lBbox = dd2MercMetersLng(lUL.lngDegrees) + "," + dd2MercMetersLat(lUL.latDegrees) + "," + dd2MercMetersLng(lLR.lngDegrees) + "," + dd2MercMetersLat(lLR.latDegrees);
        var lSRS = "EPSG:54004";
    } else {
        var lBbox = lUL.x + "," + lUL.y + "," + lLR.x + "," + lLR.y;
        var lSRS = "EPSG:4326";
    }
    var lURL = this.myBaseURL;
    lURL += "&REQUEST=GetMap";
    lURL += "&SERVICE=WMS";
    lURL += "&VERSION=" + this.myVersion;
    lURL += "&LAYERS=" + this.myLayers;
    lURL += "&STYLES=" + this.myStyles;
    lURL += "&FORMAT=" + this.myFormat;
    lURL += "&BGCOLOR=" + this.myBgColor;
    lURL += "&TRANSPARENT=TRUE";
    lURL += "&SRS=" + lSRS;
    lURL += "&BBOX=" + lBbox;
    lURL += "&WIDTH=256";
    lURL += "&HEIGHT=256";
    lURL += "&reaspect=false";
    return lURL;
}


/*
 See http://chignik.berkeley.edu/google/wmstest236.html
 var map = new GMap(document.getElementById("map"));

 // Create tile layers
 var tileCountry = new GTileLayer(new GCopyrightCollection(""), 1, 17);
 tileCountry.myLayers = 'country';
 tileCountry.myFormat = 'image/gif';
 tileCountry.myBaseURL = 'http://chignik.berkeley.edu/cgi-bin/mapserv440?map=/usr/local/web/html/google/wms.map&';
 tileCountry.getTileUrl = CustomGetTileUrl;
 //tileCountry.getOpacity = function() {return 0.5;}

 var tileCounty = new GTileLayer(new GCopyrightCollection(""), 1, 17);
 tileCounty.myLayers = 'us_county';
 tileCounty.myFormat = 'image/gif';
 tileCounty.myBaseURL = 'http://chignik.berkeley.edu/cgi-bin/mapserv440?map=/usr/local/web/html/google/wms.map&';
 tileCounty.getTileUrl = CustomGetTileUrl;
 //tileCounty.getOpacity = function() {return 0.5;}

 var tileDoq = new GTileLayer(new GCopyrightCollection(""), 1, 17);
 tileDoq.myLayers = 'doq';
 tileDoq.myFormat = 'image/jpeg';
 tileDoq.myBaseURL = 'http://terraservice.net/ogcmap.ashx?';
 tileDoq.getTileUrl = CustomGetTileUrl;

 var layer1 = [tileDoq,tileCounty];
 var layer2 = [tileCountry,tileCounty];
 var layer3 = [G_SATELLITE_MAP.getTileLayers()[0],G_HYBRID_MAP.getTileLayers()[1],tileCounty];

 var custommap1 = new GMapType(layer1, G_SATELLITE_MAP.getProjection(), "WMS 3", G_SATELLITE_MAP);
 var custommap2 = new GMapType(layer2, G_SATELLITE_MAP.getProjection(), "WMS 2", G_SATELLITE_MAP);
 var custommap3 = new GMapType(layer3, G_SATELLITE_MAP.getProjection(), "WMS 1", G_SATELLITE_MAP);

 map.getMapTypes().length = 0;
 map.addMapType(custommap3);
 map.addMapType(custommap2);
 map.addMapType(custommap1);

 map.setCenter(new GLatLng(37.8, -122.4819), 11);
 map.addControl(new GLargeMapControl());
 map.addControl(new GMapTypeControl());

 // Test adding a polyline (this caused problems in previous version of code)
 var pointArray = new Array(0);
 pointArray.push(new GLatLng(37.81, -122.48));
 pointArray.push(new GLatLng(37.81, -122.4));
 pointArray.push(new GLatLng(37.89, -122.4));
 pointArray.push(new GLatLng(37.89, -122.48));
 pointArray.push(new GLatLng(37.81, -122.48));
 var pl = new GPolyline(pointArray, '#ff00ff', 5, .5);
 map.addOverlay(pl);
 */

/** Create WMS type spec as a GMap Spec. */
function createWMSSpec(wmsURL, gName, gShortName, wmsLayers, wmsStyles, wmsFormat, wmsVersion, wmsBgColor, wmsSrs) {
    var tile = new GTileLayer(new GCopyrightCollection(""), 1, 17);
    tile.myLayers = wmsLayers;
    tile.myStyles = (wmsStyles ? wmsStyles : "");
    ;
    tile.myFormat = (wmsFormat ? wmsFormat : "image/gif");
    ;
    tile.myVersion = (wmsVersion ? wmsVersion : "1.1.1");
    tile.myBgColor = (wmsBgColor ? wmsBgColor : "0xFFFFFF");
    tile.myBaseURL = wmsURL;
    tile.getTileUrl = CustomGetTileUrl;
    //tileCounty.getOpacity = function() {return 0.5;}


    var layer = [tile];

    var mapType = new GMapType(layer, G_SATELLITE_MAP.getProjection(), gName, G_SATELLITE_MAP);

    return mapType;
}

/** Create transparent WMS overlay layer on standard GMap Spec. */
function createWMSOverlaySpec(gSpec, wmsSpec, gName, gShortName) {
    wmsSpec.getTileLayers()[0].getOpacity = function() {
        return 1.0;
    }
    var layers = [gSpec.getTileLayers()[0], wmsSpec.getTileLayers()[0]];
    return new GMapType(layers, gSpec.getProjection(), gShortName);

}

Góra

#11 - 2009-12-16 16:07:17 Reporta abuso | PermaLink
subgurim
Fecha de registro: 2006-10-18
1782 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
Hola txema,
Disculpa, pero voy un poco perdido. Por favor, échame una mano adjuntando el código javascript que se maneja con WMS y su relación con GoogleMaps.

Saludos.
Góra

#12 - 2009-12-15 18:54:27 Reporta abuso | PermaLink
txema
Fecha de registro: 2007-03-05
31 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
En teoría parece que sí pero no controla el WMS que tiene unos protocolos concretos. Revisa lo que te pasé del ICC de Cataluña.
Góra

#13 - 2009-12-14 16:09:17 Reporta abuso | PermaLink
subgurim
Fecha de registro: 2006-10-18
1782 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
Disculpa Txema, pero creo que hemos tenido una confusión común...

Lo que tú quieres no existe ya?? http://googlemaps.subgurim.net/ejemplos/ejemplo_999999_TileLayers.aspx
Góra

#14 - 2009-12-04 21:48:11 Reporta abuso | PermaLink
subgurim
Fecha de registro: 2006-10-18
1782 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
Gracias!!
Góra

#15 - 2009-12-03 14:41:10 Reporta abuso | PermaLink
txema
Fecha de registro: 2007-03-05
31 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
Aquí tienes también más información:

http://groups.google.es/group/google-maps-api/browse_thread/thread/517a51b1cfef0e8c

Saludos

Góra

#16 - 2009-12-01 14:31:37 Reporta abuso | PermaLink
txema
Fecha de registro: 2007-03-05
31 posts en todos los foros
RE: WMS

Odpowiedz Zacytuj
Gracias. Pero verás que son pocas funciones.
Góra
De en 15 Ir a página Siguientes >>

Powered by Subgurim.NET