wfs + reprojection

Mapserver, GeoServer, MapGuide, Google и другое ПО для веб-картографии
Ответить
eternal
Интересующийся
Сообщения: 26
Зарегистрирован: 26 июл 2010, 17:45
Репутация: 0

wfs + reprojection

Сообщение eternal » 23 ноя 2010, 01:52

В примере Geoserver описывается как на слой google накладывать свой слой, при этом использовать репроекцию, чтобы слой накладывался корректно (http://localhost:8080/geoserver/www/ol-demo.html)
WMS слой отображается отлично, а этот же файл в WFS никак не отображается
С чем это связано помогите разобраться, вот код

Код: Выделить всё

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>

    <script src="http://maps.google.com/maps?file=api&v=2&sensor=true_or_false&
    key=ABQIAAAAjLfEZr6uxIs9upkvgiCrVBTnDcBYKm3hU0fhORxyxbc6yGynzhSnGIUQH2L8hvQT5xlL1G0d-30NWQ" type="text/javascript"></script>

    <link rel="stylesheet" href="style-ol-demo.css" type="text/css" />

    <style type="text/css">
        body {
            margin: 1em;
        }
        #map {
            width: 95%;
            height: 512px;
            border: 1px solid gray;
        }
        div.olControlMousePosition {
            color: white;
        }
        #bounds {
            font-size: 0.9em;
        }
    </style>

    <script src="http://openlayers.org/api/OpenLayers.js"></script>
    <script type="text/javascript">
 
        // make map available for easy debugging
        var map;
		OpenLayers.ProxyHost = "../../cgi-bin/proxy.cgi?url="; 

        // avoid pink tiles
        OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
        OpenLayers.Util.onImageLoadErrorColor = "transparent";

        function init(){
            
            /**
             * The commercial layers (Google, Virtual Earth, and Yahoo) are
             * in a custom projection - we're calling this Spherical Mercator.
             * GeoServer understands that requests for EPSG:900913 should
             * match the projection for these commercial layers.  Note that
             * this is not a standard EPSG code - so, if you want to load
             * layers from another WMS, it will have to be configured to work
             * with this projection.
             */
            var options = {
                // the "community" epsg code for spherical mercator
                projection: "EPSG:900913",
                // map horizontal units are meters
                units: "m",
                // this resolution displays the globe in one 256x256 pixel tile
                maxResolution: 78271.51695,
                // these are the bounds of the globe in sperical mercator
                maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
                                                 20037508, 20037508)
            };
            // construct a map with the above options
            map = new OpenLayers.Map('map', options);

            // create Google layer
            var gsat = new OpenLayers.Layer.Google(
                "Google Satellite",
                {type: G_SATELLITE_MAP, sphericalMercator: true}
            );

            

            // you can create your own layers here

            // create WMS layer
            var us = new OpenLayers.Layer.WMS(
                "TOPP States",
                "http://localhost:8080/geoserver/wms?",
                {
                   layers: 'topp:states',
                   styles: '',
                   srs: 'EPSG:4326',
                   format: 'image/png',
                   tiled: 'true',
                   tilesOrigin : "143.60260815000004,-43.851764249999995",
                   transparent: true
                },
                {
                    'opacity': 0.75, 'isBaseLayer': false, 'wrapDateLine': true
                }
            );
			
			wms = new OpenLayers.Layer.WMS(
                    "belgorod-bound - Tiled", "http://localhost:8080/geoserver/wms",
                    {
                        height: '330',
                        width: '700',
                        layers: 'my:belgorod-bound',
                        styles: '',
                        srs: 'EPSG:4326',
                        format: 'image/png',
                        tiled: 'true',
                        tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom,
						transparent: true
                    },
                    {
						'opacity': 0.6, 'isBaseLayer': false, 'wrapDateLine': true
                        
                    } 
                );
			
			var wfs = new OpenLayers.Layer.Vector('Слой WFS', {
        strategies: [new OpenLayers.Strategy.Fixed({preload: true})],
        protocol: new OpenLayers.Protocol.WFS({
            version: '1.0.0',
            url: 'http://localhost:8080/geoserver/wfs',
            featureType: 'belgorod-bound',
            featureNS: 'http://my.ru',
            srsName: 'EPSG:4326'
        }),
        visibility: true
    });

            var usBounds = new OpenLayers.Bounds(
                -14392000, 2436200, -7279500, 6594375
            );
			var belBounds = new OpenLayers.Bounds(
                3424952.812153, 6273950.646471, 4954916.370035, 6900122.782071
            );

            // add the created layers to the map
            // (if you want custom layers to show up they must be here as well)
            map.addLayers([gsat, us, wms, wfs]);
            
            map.addControl(new OpenLayers.Control.LayerSwitcher());
            map.addControl(new OpenLayers.Control.MousePosition());
            map.zoomToExtent(belBounds);
            
            // the part below is just to make the bounds show up on the page
            var boundsOutput = document.getElementById('bounds');
            function updateBounds() {
                var code =
                    "    var bounds = new OpenLayers.Bounds(\n" +
                    "        " + map.getExtent().toBBOX().replace(/,/g, ', ') + "\n" +
                    "    );\n" +
                    "    map.zoomToExtent(bounds);"
                boundsOutput.innerHTML = code;
            }
            // update the bounds with each map move
            map.events.register('moveend', map, updateBounds);
            // and update the bounds on first load
            updateBounds();
        }
        
    </script>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
  <body onLoad="init()">
    <h3>Geoserver OpenLayers Demo</h3>
    <div id="map"></div>
    <p>In creating your own OpenLayers application, you can use the bounds shown
    above as your initial extent.  For example, the following code would zoom
    your map to the current extent:
    </p>
    <pre id="bounds"></pre>
  </body>
</html>
FireBug ошибок не выдает, пишет вот это:
PluralForm.jsm: Index #2 of '6 запрос;6 запросов' for value 6 is invalid -- plural rule #7; called by $STRP
PluralForm.jsm: Index #2 of '6 Firebug;Всего 6 Firebug'ов' for value 6 is invalid -- plural rule #7; called by $STRP
PluralForm.jsm: Index #2 of '6 Firebug;Всего 6 Firebug'ов' for value 6 is invalid -- plural rule #7; called by $STRP
POST http://localhost/cgi-bin/proxy.cgi?url= ... rver%2Fwfs 200 OK 189 ms
OpenLayers.js (строка 1188)

в ответ POST виден большой список координат, слой загружается но не отображается

Аватара пользователя
Mavka
Гуру
Сообщения: 2060
Зарегистрирован: 14 мар 2008, 17:36
Репутация: 9

Re: wfs + reprojection

Сообщение Mavka » 23 ноя 2010, 11:08

Поищите векторный слой на экваторе в Гвинейском заливе. Он там будет маленький-маленький.

Добавьте в описание слоя 'projection':

Код: Выделить всё

var wfs = new OpenLayers.Layer.Vector('Слой WFS', {
    strategies: [new OpenLayers.Strategy.Fixed({preload: true})],
    protocol: new OpenLayers.Protocol.WFS({
        version: '1.0.0',
        url: 'http://localhost:8080/geoserver/wfs',
        featureType: 'belgorod-bound',
        featureNS: 'http://my.ru',
        srsName: 'EPSG:4326'
    }),
    projection: new OpenLayers.Projection("EPSG:4326"),
    visibility: true
}); 
Или измените 'srsName' на 'epsg:900913'.
лангольеры под окном жрали время ом-ном-ном

eternal
Интересующийся
Сообщения: 26
Зарегистрирован: 26 июл 2010, 17:45
Репутация: 0

Re: wfs + reprojection

Сообщение eternal » 10 дек 2010, 14:29

Помогло спасибо =)

Аватара пользователя
Mavka
Гуру
Сообщения: 2060
Зарегистрирован: 14 мар 2008, 17:36
Репутация: 9

Re: wfs + reprojection

Сообщение Mavka » 10 дек 2010, 15:43

Чисто для справки: srsName появился только в WFS 1.1.0, а в версии 1.0.0 проекция всегда espg:4326.
Заставить UMN MapServer работать с WFS 1.1.0 у меня не получилось :(
лангольеры под окном жрали время ом-ном-ном

Ответить

Вернуться в «Веб-картография»

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и 6 гостей