0

I have a WFS layer:

myVecLayer_disp= new OpenLayers.Layer.Vector("Редактируемый участок",{projection: new OpenLayers.Projection("EPSG:900913")});

And i have feature store:

        var protocol=new OpenLayers.Protocol.HTTP({
            url: url_servlet+"fullSearch.jsp",
            format: new OpenLayers.Format.GeoJSON({internalProjection: new OpenLayers.Projection("EPSG:4326"),externalProjection:new OpenLayers.Projection("EPSG:900913")})
    });
    searchStore = new GeoExt.data.FeatureStore({
        layer: myVecLayer_disp,
        fields: [
            {name: 'id', type: 'String'},
            {name: 'name_dispatcher', type: 'String'},
            {name: 'voltage', type: 'String'},
        ],
        proxy: new GeoExt.data.ProtocolProxy({
            protocol: protocol,
        }),
        autoLoad: true,
        layerOptions: function() {
            return {
                strategies: [new OpenLayers.Strategy.BBOX()],
                //projection:"EPSG:4326"
            };
        }
    });

As you see i use GeoJSON. In this geojson i have features in wgs84. And reproject it in mercator in protocol. Now i show this layer:

    app.mapPanel.map.addLayers(myVecLayer_disp);
myVecLayer_disp.visibility=true;

And see features near Africa but expect to see it within Russia. So Nothig reproject i think. But when i see layes's features:

    LINESTRING(0.00055807640304122 0.00050642147755534,0.00055807616948463 
0.00050641930362077,0.00055807588202664 0.00050641664462617,0.00055807423809849 
0.00050641332981391,0.00055807306129967 0.00050640979946183,0.00055807191147579 
0.00050640644872202,0.00055807052802261 0.00050640231648177,0.00055806910873212 
0.00050639813934481,0.00055806841697321 0.00050639609116937,0.00055806763547558 
0.00050639388128181)

Ant this is same feature in geojson:

{"type":"LineString","coordinates":[[62.124781001642077,56.374581001212391],
[62.124755002241727,56.374338999945053],[62.124723002564679,56.374043002482722],
[62.124540001320156,56.373673997157425],[62.12440900067503,56.373281000617851],
[62.124281002866155,56.37290799870533],[62.124126997563053,56.372447999975407],
[62.123969002867341,56.371983002813522],[62.123891996618511,56.371755002191776],
[62.123805000700372,56.371508997142655]]}

What i doing wrong?

1 Answer 1

1

Find a simple sollution. At first i says that if you put features in projection another that WGS84 (i try use EPSG900913) in geoJSON in openlayers you get in anyway in WGS84. So you gonna reproject coordinates only in openalyers side.
I try to use:

        var protocol=new OpenLayers.Protocol.HTTP({
        url: url_servlet+"fullSearch.jsp",
        format: new OpenLayers.Format.GeoJSON({internalProjection: new OpenLayers.Projection("EPSG:4326"),externalProjection:new OpenLayers.Projection("EPSG:900913")})
});

But you can see result in feature example in my question.
For all work fine you gonna change internalProjection->externalProjection so correct syntax:

            var protocol=new OpenLayers.Protocol.HTTP({
        url: url_servlet+"fullSearch.jsp",
        format: new OpenLayers.Format.GeoJSON({externalProjection: new OpenLayers.Projection("EPSG:4326"),internalProjection:new OpenLayers.Projection("EPSG:900913")})
});

And feature will:

    LINESTRING(6915698.9857838 7633348.4049681,6915696.0915438
 7633299.7569566,6915692.529356 7633240.2548455,6915672.1577506 
7633166.0771681,6915657.5748255 7633087.0775519,6915643.3261746 
7633012.0979814,6915626.1823827 7632919.6316184,6915608.5944936 
7632826.1616331,6915600.0221972 7632780.3312007,6915590.3378559 7632730.8820038)

I can be wrong but its help me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.