Bug 872 - [MapLab] GMapFactory projection problem with ms 4.4-beta3
: [MapLab] GMapFactory projection problem with ms 4.4-beta3
Status: RESOLVED FIXED
: MapLab
SECT (Maplab)
: 2.1
: PC Windows XP
: P1 blocker
: ---
Assigned To:
:
:
:
:
:
  Show dependency treegraph
 
Reported: 2004-11-27 15:36 by
Modified: 2005-02-24 07:57 (History)


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2004-11-27 15:36:38
A user reported a problem when he converted to mapserver 4.4...his mapfile can
be viewed in MapEdit preview but cannot be viewed in GMapFactory.  I can also
reproduce the error.  If I remove the need to reproject the data in the mapfile
my gmapfactory application works fine (the map image is displayed).  If I change
globprefs.php to use mapscript_42 (and force mapserver to reproject) the
gmapfactory application works perfect.  Definite problem with 4.4 and
projections for GMapFactory.  
The map image appears blank on the page, but using setenv MS_ERRORFILE these
errors occur:

Sat Nov 27 15:11:05 2004 - msInsertHashTable: Hash table error. Invalid hash
table or key
Sat Nov 27 15:11:05 2004 - msInsertHashTable: Hash table error. Invalid hash
table or key
Sat Nov 27 15:11:05 2004 - msProcessProjection(): Projection library error.
projection not named
Sat Nov 27 15:11:05 2004 - msProcessProjection(): Projection library error.
projection not named
------- Comment #1 From 2004-11-27 18:18:10 -------
I've managed to narrow the problem to one line, in
~/yourgmapfactoryapp/wrapper/map_session.php if I comment out the following line
my application works with both php_mapscript 42 and 44:

line 845 $this->oMap->setprojection(implode( "\n", split( " ", $aszKeys["SRS"] ) ));

Can someone explain what this line is supposed to do?  here is some more of the
code:
  function restoreState(...)
  {
        ...
        // set the projection if not empty
        if ( isset($aszKeys["SRS"]) && $aszKeys["SRS"] != "" )
        {
           // srs can contain "="
           $this->oMap->setprojection(implode( "\n", split( " ", $aszKeys["SRS"]
) ));
        }
        ...
  } 
------- Comment #2 From 2004-11-27 18:23:01 -------
ok, before someone answers "it's supposed to set the projection"...yes but why
would this cause an error with mapscript 44 and not 42?  and if it's not a
necessary line I think it should be removed.
------- Comment #3 From 2004-11-28 14:31:27 -------
note that problem occurs with mapserver 4.4-beta2 and beta3.
------- Comment #4 From 2004-11-29 10:38:03 -------
The following error:
  msProcessProjection(): Projection library error. projection not named
is likely caused by passing an empty projection to setProjection(). i.e. in the
code that you quoted, $aszKeys["SRS"] would be empty. The maintainer of the
wrappers stuff should look into that. If you'd expect that passing an empty
projection should unset it, then please file a enhancement bug in MapServer.


With respect to the other error:
  msInsertHashTable: Hash table error. Invalid hash table or key
You'd get that if you call setMetadata() with a null hashtable, key or value.
However I can't seem to reproduce that even by passing null value explicitly to
the function. If someone can create a test case that reproduces this and submit
a mapserver bug then I can have a look.
------- Comment #5 From 2004-11-29 10:55:39 -------
Paul and Zak just helped me debug this.  It appears to be a bug in
phpmapscript's setProjection() function.

$oMap->setProjection(" init=epsg:42304");  // notice the space

  with phpmapscript_44_beta2&3.dll --> throws error

  with phpmapscript_42.dll -- no error

42 looks to be using a trim() function whereas 44 is not.


------- Comment #6 From 2004-11-29 13:57:37 -------
This is not new to MapServer 4.4: I get the same error with both versions on my
machine. Perhaps something changed in PROJ?  Can you find out which versions of
PROJ were used by your respective builds of MapScript?
------- Comment #7 From 2004-11-29 14:01:05 -------
FYI I'm using PROJ 4.4.8 for both php_mapscript 4.2 and 4.4 and I get this
"projection not named" error in both cases when I pass " init=epsg:42304". Let's
see which versions you have.

I CC'd Frank, he may be aware of some changes in PROJ that could have cause that.
------- Comment #8 From 2004-11-29 14:04:47 -------
To state the obvious, EPSG:42304 is not a real EPSG projection and is not
distributed in the normal "epsg" definition file.  It is distributed with
PROJ.4 in the other.extra file.  Have you pasted the other.extra file into
your epsg definition file? 
------- Comment #9 From 2004-11-29 14:12:11 -------
That's not the problem Frank: the problem is the space at the beginning of the
projection string. It seems that PROJ 4.4.8 (at least) doesn't like receiving
" proj=..."
------- Comment #10 From 2004-11-29 14:20:52 -------
Ah, sorry.  That's what I get for not reading over things carefully.
------- Comment #11 From 2004-11-29 14:28:50 -------
I'm using PROJ: Rel. 4.4.6, 3 March 2003
------- Comment #12 From 2004-11-29 14:42:38 -------
sorry my turn for misunderstanding.

Assefa believes both 4.2 and 4.4 mapscript versions used the same proj (build in
July 2003)


------- Comment #13 From 2004-11-29 15:29:32 -------
Um... maybe we could patch MapServer to trim leading spaces but that implode(
"\n", ...) doesn't smell good anyway. I tested this code and it won't work with
projection definitions with more than one parameter unless you prefix your
projection parameters with "+", in which case you don't need the implode at all
since passing a "+"-delimited string directly works. 

The right way to pass projection definitions to PROJ are using "+" prefixes, or
comma-separated parameters with no spaces:

"+init=epsg:42304"
or
"+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat_1=49 +lat_2=77 +datum=NAD83
+units=m"
or
"proj=lcc,ellps=GRS80,lat_0=49,lon_0=-95,lat_1=49,lat_2=77,datum=NAD83,units=m"

The reason why "init=epsg:42304" also works it's because it falls in the
comma-separated case.
------- Comment #14 From 2005-02-23 17:10:14 -------
Paul, Zak, Bill, we ran into this again and need some answers on this.

The following code from map_session.php can't work for the reasons explained in
comment #13 above. Can whoever wrote it please explain why this implode("\n",
split(...)) is there? If not then I'll take it out:

        // set the projection if not empty
        if ( isset($aszKeys["SRS"]) && $aszKeys["SRS"] != "" )
        {
           // srs can contain "="
           $this->oMap->setprojection(implode( "\n", split( " ", $aszKeys["SRS"]
) ));
        }
------- Comment #15 From 2005-02-23 17:17:44 -------
Never mind. I have removed the bogus implode() in
php_utils/wrapper/map_session.php. If you know of a better fix then please go ahead.

Not sure in which maplab release this will be included.
------- Comment #16 From 2005-02-23 17:25:39 -------
thank you
------- Comment #17 From 2005-02-24 07:57:39 -------
To shed a bit more light on the subject, after a quick check, I have found that
the implode was added in version 1.50 (I wont say by who ;)).

The comment says:

"fixed handling of projection through URL if it was a multiline projection
definition."

Paul do you recall what you meant by that?  Is this going to cause issues?
.....oops sorry....I guess I let the cat out of the bag ;)