Comments (13)
fix in #6897
from mapserver.
@wicksell - maybe #6279 could have caused this. If you are able to roll back this change and test that would be helpful. Alternatively rather than recompiling could you try setting the extent of all your layers once you have switched projection to see if you get an image?
map.setProjection("init=epsg:3006");
map.setSize(256, 256);
map.setExtent(642080, 7198656, 642112, 7198688);
// TODO loop through all layers in the map and set the extent on these in the new projection
from mapserver.
(I'm not sure my comment here is useful, or if I am testing something different by accident) : I've run a few tests with PHP MapScript, on Windows with MS4W 5.0 : with MapServer 7.6.5 I don't have to re-declare the new mapObj instance, but with MapServer-git-main I must always re-declare, with something like $oMap = new mapObj(path);
otherwise I get a blank image when trying the second reprojection. (setting layer extent does not affect the problem)
from mapserver.
Tomorrow I will add in a hint in the documentation, that the layer extent is actually in the coordinates of the layer source projection (this is not so clear I think, for the user, who might assume that the layer extent is in the 'new' (MAP) projection coordinates. Ok, sorry for my confusing comments, will wait for @wicksell response, ha.
from mapserver.
I have tested looping over all layers after setting the new projection. Setting the extent in the layers projection, as I understand is the correct way, has no effect. Setting it to the an extent in the map projection give error "msProjectRect(): Projection library error. All points failed to reproject. (message repeated 1 times)".
I have the same results as described above by @jmckenna, in 8.0.x i get a blank image if I don't reload the map with new mapObj(path);
. The strange thing is that this only occur if the layer is in WGS84, however I have not tested all projections :), and not when the layer is in SWEREF99 TM.
I will try rolling back #6279 and see if that helps.
from mapserver.
I have now tried to roll back #6279 and unfortunately it had no effect.
from mapserver.
I have tested more to find a workaround and then come to slightly different conclusions than before. It is only possible to change the projection once, regardless of which projection the data is in. Then the map can be used with its initial projection or the first projection that it was changed to. Other projections can not be used until a new mapObj
is created.
from mapserver.
@wicksell - I was able to recreate and came to the same conclusion. Whatever projection is first used can always be used but any other projections don't return data in the image. I can see why it is happening, but not the cause..
The shapes are reprojected here:
Line 2110 in db74212
I tested using a projection without a change and then using a different projection first. In both cases the reprojectorLayerToMap and shape seem identical when passed in to the function (same bounds, points etc.), and as far as I can tell the reprojector object looks the same:
in: 0x000002081119dd10 {args=0x00000208144e4400 {0x00000208150f5380 "init=epsg:4326"} proj=0x0000020813921fa0 {...} ...}
out: 0x0000020813c5b220 {args=0x0000020814480760 {0x00000208150f55a0 "init=epsg:3006"} proj=0x0000020814f02d40 {...} ...}
pj: 0x00000208133401c0 {...}
lineCuttingCase: LINE_CUTTING_UNKNOWN
splitShape: {line=0x0000000000000000 <NULL> values=0x0000000000000000 {???} geometry=0x0000000000000000 ...}
bFreePJ: 0
However the broken version does not correctly return the shape - its bounds are incorrect for the target projection:
Working shape
before reprojection: bounds: {minx=17.997981199564393 miny=64.881029549666493 maxx=18.004429230036195 ...}
Working shape
after reprojection:
numlines: 1
numvalues: 0
bounds: {minx=17.997981199564393 miny=64.881029549666493 maxx=18.004429230036195 ...}
Broken shape
before reprojection: bounds: {minx=17.997981199564393 miny=64.881029549666493 maxx=18.004429230036195 ...}
Broken shape
after reprojection:
numlines: 0
numvalues: 0
bounds: {minx=2003526.1024424192 miny=9577103.7174967937 maxx=2004243.8939111596 ...}
Then as numlines
is 0 the function stops before drawing the feature at
Line 2248 in db74212
In conclusion there is something different with the reprojections (a cached object? something different in the projectionContext
?) - but I'm unable to find out what it is.
from mapserver.
Probably msProjectShapeLine
return MS_FAILURE
at
Line 1732 in db74212
or
msProjectLineEx
return MS_FAILURE
atLine 1734 in db74212
resulting in line being deleted from the shape.
I think there should be a check if at msProjectShapeEx
returns MS_FAILURE
at
Line 2110 in db74212
so that these issues not just pass by unnoticed.
from mapserver.
@wicksell - no errors are thrown when reprojecting. It appears the feature is correctly reprojected to the first projection used, and therefore isn't rendered. The points are reprojected using the "cached"/first projection here:
Line 1056 in db74212
Even though the reprojector->pj
looks to have the correct 2 projections:
in: 0x00000189beaef860 {args=0x00000189bea6ae70 {0x00000189bceb58e0 "init=epsg:4326"} proj=0x00000189beaf05a0 {...} ...}
out: 0x00000189bcb5ad00 {args=0x00000189befd7060 {0x00000189bee6ed10 "init=epsg:3006"} proj=0x00000189bee77c30 {...} ...}
When setting the projection in MapScript the following function is called:
Line 1333 in db74212
I'm guessing something is cached in the projection context that causes this?
@rouault any ideas? Recreating a new projection context is presumably costly, but could maybe be added to the MapScript setProjection
call only?
from mapserver.
any ideas?
I'm on it
from mapserver.
Sorry to drag you in to the ticket..I need to sort out some PROJ debug builds so I can look into these myself..
Here was my test script in Python based on the example Mapfile and data in the zip attached to the ticket.
import mapscript
import os
pth = r"D:\Temp\test-change-projection\wgs84"
map = mapscript.mapObj(os.path.join(pth, "test.map"))
map.setProjection("init=epsg:3857")
map.setSize(256, 256)
map.setExtent(2003499.4,9577066.7,2003987.7,9577395.3)
image1 = map.draw()
image1.save(os.path.join(pth, "myimage.png"), map)
map.setProjection("init=epsg:3006")
map.setSize(256, 256)
map.setExtent(642080, 7198656, 642112, 7198688)
image2 = map.draw()
image2.save(os.path.join(pth, "myimage2.png"), map)
from mapserver.
Big thanks for resolving this issue so quickly! I have tested the pull request with 8.0.1 and it works great :)
from mapserver.
Related Issues (20)
- MSSQL query is really slow because of ORDER BY HOT 8
- Projection error EPSG:2391->3877 but not ->3067 HOT 2
- PHPMapscript 8 : save mapfile with CONNECTIONOPTIONS HOT 4
- Memory leak in LayerDefaultGetNumFeatures HOT 1
- Native FlatGeoBuf from MapServer is not working for files with non specific geometry type HOT 4
- build 8.0.1 on WIndows failed HOT 6
- Queries that find no results not returning and error message HOT 5
- Oddball crash with old version of PostGIS HOT 1
- List Expressions not output to SLD
- Wrong scale computed in tile mode HOT 6
- SLD styling ignored without error when CONNECTIONTYPE is POSTGIS. HOT 2
- uvraster not rendered correctly HOT 8
- Exception thrown with mapserv.exe & PROJ 9.2.1 HOT 6
- POSTGIS Datasource + Cluster throws error
- Invalid namespace declarations in WFS DescribeFeatureType responses HOT 2
- MapScript PHP SWIG OWSRequest loadParams problem HOT 10
- Line-Classes with multiple Styles not displayed correctly when using attributes HOT 2
- PHP-/SWIG-Mapscript WFS GetPropertyValue: HTTP Headers in Textbody HOT 5
- Proposal for renaming/replacing SWIG-Mapscript functions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapserver.