Openlayers加载WFS层非常慢

时间:2013-12-08 23:02:30

标签: javascript jquery performance openlayers geoserver

我一直在测试WFS图层的速度:

一种方法(openlayers方式)

station_layer = new OpenLayers.Layer.Vector(
    'Active Stations',
    {
        strategies: [new OpenLayers.Strategy.Fixed()],
        projection: new OpenLayers.Projection("EPSG:4326"),
        format: "GeoJSON",
        protocol : new OpenLayers.Protocol.WFS(
        {
            srsName : "EPSG:900913",
            url: "NOT REALLY EMPTY",
            featureNS : "NOT REALLY EMPTY",
            featurePrefix: "NOT REALLY EMPTY",
            featureType : "NOT REALLY EMPTY",
            outputFormat: "json",
            readFormat: new OpenLayers.Format.GeoJSON(),
        }),
    }
);

map.addLayers([google_hybrid, google_physical, google_satellite, station_layer]);

加载时间巨大

等待:3.73秒

接收:2.66秒

或者我们可以手动将其添加到功能对象

    var url = geo_url +"/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=LAYER&outputFormat=json";
    station_layer = new OpenLayers.Layer.Vector("Stations");

    var geojson_format = new OpenLayers.Format.GeoJSON({
        'internalProjection': map.baseLayer.projection,
        'externalProjection': new OpenLayers.Projection("EPSG:4326")
    });

    $.ajax({
        url: base_url + '?task=proxy',
        data:
        {
          url: url,
          json: true
        },
    }).done(function(results)
    {
        var gformat = new OpenLayers.Format.GeoJSON();
        map.addLayer(station_layer);
        station_layer.addFeatures(geojson_format.read(results));
    });
}

加载时间要好得多

等待:325毫秒

接收:1.02秒

他们都返回完全相同的功能集合!

现在我使用openlayers API是错误的,还是openlayers编码对于我正在做的事情来说只是慢一点?

0 个答案:

没有答案