#564 closed defect (fixed)
Label are occassional upside down
Reported by: | Owned by: | sdlime | |
---|---|---|---|
Priority: | high | Milestone: | 4.6 release |
Component: | MapServer C Library | Version: | 4.0 |
Severity: | normal | Keywords: | |
Cc: |
Description
I am getting occassional labels that are upside down. This feels like a corner case that is not be checked properly. I looked at the code but it was not clear to me how the angle was be detected and flipped if it was upside down. Here is the software that I'm running on debian stable Woody: curl-7.11.0 freetype-2.1.5.tar.gz owt-20031104.tar.gz curl-7.11.0.tar.gz gd-2.0.21 php-4.3.4 doit-all gd-2.0.21.tar.gz php-4.3.4.tar.gz doit-mapserver gdal-1.1.9 proj-4.4.7 doit-php gdal-1.1.9.tar.gz proj-4.4.7.tar.gz expat-1.95.7 mapserver-4.0.1 shapelib-1.2.10 expat-1.95.7.tar.gz mapserver-4.0.1.tar.gz shapelib-1.2.10.tar.gz freetype-2.1.5 owt-20031104 it is compiled using the following options: swoodbridge@maps5:/u/software$ cat doit-all # # first untar the source archives for X in *.gz ; do tar xzf $X ; done # make sure we have the required system packages # required by gd-2 sudo apt-get install libpng libpng-dev sudo apt-get install libjpeg62 libjpeg62-dev # required by php4 sudo apt-get install libmysqlclient10-dev # required by owt sudo apt-get install libttf-dev libttf2 # For curl-7.11.0.tar.gz ( cd curl-7.11.0 ./configure --prefix=/opt/mapserver/ make sudo make install ) # For freetype-2.1.5.tar.gz ( cd freetype-2.1.5 ./configure --prefix=/opt/mapserver/ make sudo make install ) # For gd-2.0.21.tar.gz ( cd gd-2.0.21 ./configure --prefix=/opt/mapserver/ --with-freetype=/opt/mapserver/ make sudo make install ) # For gdal-1.1.9.tar.gz ( cd gdal-1.1.9 ./configure --prefix=/opt/mapserver/ --with-ogr --without-gif make sudo make install ) # For proj-4.4.7.tar.gz ( cd proj-4.4.7 ./configure --prefix=/opt/mapserver/ make sudo make install ) # For expat-1.95.7.tar.gz ( cd expat-1.95.7 ./configure --prefix=/opt/mapserver/ make sudo make install ) # For php-4.3.4.tar.gz ( cd php-4.3.4 ./configure \ --enable-dbase \ --enable-force-cgi-redirect \ --with-config-file-path=/opt/mapserver/php4 \ --with-regex=system \ --with-gd=/opt/mapserver \ --with-ttf=/opt/mapserver \ --enable-gd-native-ttf \ --with-freetype-dir=/opt/mapserver \ --without-xpm \ --with-mysql=/usr make sudo make install sudo mkdir -p /opt/mapserver/php4/extensions sudo sapi/cgi/php /opt/mapserver/php4/ sudo cp php.ini-recommended /opt/mapserver/php4/php.ini #-------------------------------------------------- echo "You need to edit /opt/mapserver/php4/php.ini" echo " and setup the session handling for chameleon" #-------------------------------------------------- ) # For mapserver-4.0.1.tar.gz ( cd mapserver-4.0.1 #------------------------------------------------------ echo "You need to edit map.h and change MS_MAXLAYERS to 175" echo "and then comment out the exit command on the next line" exit; #------------------------------------------------------ ./configure \ --with-httpd=/usr/sbin/apache \ --with-proj=/opt/mapserver \ --with-wmsclient \ --with-gd=/opt/mapserver \ --with-freetype=/opt/mapserver \ --with-gdal \ --with-ogr=/opt/mapserver/bin/gdal-config \ --with-php=../php-4.3.4 \ --without-tiff \ --enable-runpath \ --without-xpm \ --with-curl-config=/opt/mapserver/bin/curl-config make sudo mkdir /opt/mapserver/cgi-bin sudo cp mapserv scalebar legend /opt/mapserver/cgi-bin/ sudo cp mapscript/php3/php_mapscript.so /opt/mapserver/php4/extensions/ ) # For owt.tar.gz ( cd owt-20031104 make sudo cp owtchart/owtchart /opt/mapserver/cgi-bin/ ) # For shapelib-1.2.10.tar.gz ( cd shapelib-1.2.10 ) swoodbridge@maps5:/u/software$
Attachments (3)
Change History (14)
by , 20 years ago
Attachment: | railroad-upside-down.png added |
---|
comment:1 by , 19 years ago
Cc: | added |
---|
I just downloaded Mapserver 4.4.1 and con confirm that this bug still exists. I know you would like a test case, but I think it would be very hard to extract the data to a separate set of shapefiles. I can reproduce this easily and reliably on a map that is not very detailed like this one http://data.dev.where2getit.com/cgi-bin/mapserv?mode=map&layers=all&scale=25000&map=/home/direct/mapserver/default_mapfile.map&mapxy=-71.38918+42.61935&map_size=300+200
comment:2 by , 19 years ago
OK, I have made a trivial example that reproduces this problem http://data.dev.where2getit.com/cgi-bin/mapserv?mode=map&layers=all&map=/u/work/swoodbridge/angles/angles.map&mapxy=0+0&mapsize=800+800 I will attach a tarball with a shapefile and mapfile. I seems that this problem may be related to POSITION AUTO because when I use POSITION CC all the labels look OK, but that might be just a side effect that masks the real issue.
by , 19 years ago
Attachment: | angles.tgz added |
---|
Tar file with shapefile and mapfile to reproduct upside down labels.
comment:3 by , 19 years ago
Cc: | added |
---|---|
Milestone: | → 4.6 release |
Owner: | changed from | to
Now that we have a test case let's see if we can get it fixed for 4.6. I'll at least see if I can reproduce at my end.
comment:4 by , 19 years ago
Status: | new → assigned |
---|
I found the issue and think I fixed it, it was an angle passed to the cos() function in degrees instead of radians. Unfortunately I'm unable to commit to CVS at the moment due to a lock problem on the CVS server. You can try the following patch to confirm that it works for ou and then I'll backport to 4.4. diff -u -r1.98 mapgd.c --- mapgd.c 28 Feb 2005 14:17:49 -0000 1.98 +++ mapgd.c 20 Apr 2005 19:39:30 -0000 @@ -2869,7 +2869,7 @@ cachePtr->status = MS_TRUE; /* assume label *can* be drawn */ if(j == 1) { - if(fabs(cos(labelPtr->angle)) < LINE_VERT_THRESHOLD) + if(fabs(cos(labelPtr->angle*MS_DEG_TO_RAD)) < LINE_VERT_THRESHOLD) labelPtr->angle += 180.0; else position = MS_LC;
comment:5 by , 19 years ago
Fixes committed to 4.5 CVS. Steve W, can you please test and confirm that the fix works for all your testcases and then I'll backport to 4.4.
comment:6 by , 19 years ago
Daniel, This looks much better, but there may be another problem. The labels on angles 81-89 look like they are flipped. Change the mapfile to "POSITION CC" instead of "POSITION AUTO" and all these labels will flip. I would expect the same orientation of labels regardless of POSITION setting. I have not checked any of the other POSITION values to see what they look like. I backported the patch to MS 4.4.1 and did my testing there.
comment:7 by , 19 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
Good Catch. That's because of the following test in msDrawLabelCacheGD(): if(j == 1) { if(fabs(cos(labelPtr->angle*MS_DEG_TO_RAD)) < LINE_VERT_THRESHOLD) labelPtr->angle += 180.0; else position = MS_LC; } This test never really worked before because of the missing MS_DEG_TO_RAD that I added yesterday, but now that it's working, it seems that it flips any label between 81 and 90 degrees. LINE_VERT_THRESHOLD is defined as 0.17, and arccos(0.17) = 80.2, that's why you now see all labels between 81 and 89 degrees flipped. Unfortunately I have no clue what this test is for or what it's trying to do exactly. I'll have to reassign to Steve Lime since I presume he is the author of this code.
comment:8 by , 19 years ago
Man, now you're really testing my memory. The test is there to deal with nearly vertical lines, but I'll have to think about it and run a few test cases I've got squirreled away to recall why I added it. If things were busted because of the missing conversion perhaps that is why it was added in the first place. I'll look though... Steve
comment:9 by , 19 years ago
Cc: | added |
---|---|
Status: | new → assigned |
I played with that code and Steve's example (great one by the way, need to hold onto that for any font testing) and really couldn't recreate my train of thought on that test. So, I removed the test and the angle output looks good. I noticed that Assefa is using that same test within the pdf|svg|swf sources and it should be removed there as well, and then the LINE_VERT_THRESHOLD should be removed from maplabel.c. CC'ing Assefa to make sure that's ok to do. I'll make the changes once ok'd. Will post the angle output image next... Steve Steve W. - Thanks for your persistance on this one. Wish I would have had your sample shapefile during development. I only had a 20 line shapefile which missed the problem angles.
comment:10 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Didn't hear any objections so I pulled that LINE_VERT... test from the SWF/PDF/SVG and imagemap drivers. Calling this one closed. Steve
Note:
See TracTickets
for help on using tickets.
railroad-label-upside-down