[GeoNetwork-users] customizing the GN 3 map viewer

Thanks for that Florent. I can confirm that attempting to load the default map from the map panel fails (Bing remains). In Chrome debug tools console the stack trace:

TypeError: Cannot read property 'a' of null
    at se (lib.js:809)
    at te (lib.js:809)
    at Object.ek [as transformExtent] (lib.js:810)
    at k.service.loadContext (gn_search_default.js:463)
    at gn_search_default.js:465
    at lib.js:417
    at lib.js:448
    at k.$get.k.$eval (lib.js:462)
    at k.$get.k.$digest (lib.js:459)
    at k.$get.k.$apply (lib.js:462)(anonymous function) @ lib.js:438$get @ lib.js:413(anonymous function) @ lib.js:448$get.k.$eval @ lib.js:462$get.k.$digest @ lib.js:459$get.k.$apply @ lib.js:462m @ lib.js:418N @ lib.js:422w.onload @ lib.js:423

appears. Given lib.js is a large minified JS file it isn't very informative. I imagine that means it's either failing to find my context file, or there is an error in the XML/the XML is incomplete in some way?

Thanks again,

David.

________________________________
This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system.
________________________________

Add ?debug to your url before the #
You'll get more info

On Tue, Jul 28, 2015 at 4:59 PM, Herbert, David J. <darb1@anonymised.com> wrote:

Thanks for that Florent. I can confirm that attempting to load the
default map from the map panel fails (Bing remains). In Chrome debug tools
console the stack trace:

TypeError: Cannot read property 'a' of null
    at se (lib.js:809)
    at te (lib.js:809)
    at Object.ek [as transformExtent] (lib.js:810)
    at k.service.loadContext (gn_search_default.js:463)
    at gn_search_default.js:465
    at lib.js:417
    at lib.js:448
    at k.$get.k.$eval (lib.js:462)
    at k.$get.k.$digest (lib.js:459)
    at k.$get.k.$apply (lib.js:462)(anonymous function) @ lib.js:438$get @
lib.js:413(anonymous function) @ lib.js:448$get.k.$eval @
lib.js:462$get.k.$digest @ lib.js:459$get.k.$apply @ lib.js:462m @
lib.js:418N @ lib.js:422w.onload @ lib.js:423

appears. Given lib.js is a large minified JS file it isn't very
informative. I imagine that means it's either failing to find my context
file, or there is an error in the XML/the XML is incomplete in some way?

Thanks again,

David.

________________________________
This message (and any attachments) is for the recipient only. NERC is
subject to the Freedom of Information Act 2000 and the contents of this
email and any reply you make may be disclosed by NERC unless it is exempt
from release under the Act. Any material supplied to NERC may be stored in
an electronic records management system.
________________________________

------------------------------------------------------------------------------
_______________________________________________
GeoNetwork-users mailing list
GeoNetwork-users@lists.sourceforge.net
geonetwork-users List Signup and Options
GeoNetwork OpenSource is maintained at
GeoNetwork - Geographic Metadata Catalog download | SourceForge.net

--
*camptocamp*
INNOVATIVE SOLUTIONS
BY OPEN SOURCE EXPERTS

*Florent Gravin*
0479444492

Hi Florent,

This was indeed helpful. I think I can now see what the problem is – GN can’t load my context due to problems with the projection (in particular OL transforming from Mercator to 3031). Looking at the traceback I now get and using Chrome debugger to investigate further suggests that our CRS EPSG:3031 isn’t understood natively by Proj4js. I have seen this in my own OL applications for the Antarctic region. I have had to manually load a 3031.js defs file e.g:

proj4.defs("EPSG:3031","+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs");
proj4.defs("urn:ogc:def:crs:EPSG::3031","+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs");

to ensure that Proj4js can do transforms etc. So it seems like a good way forward might be to get GN to load this projection definition. I imagine I can at least test this by adding the above lines manually to the appropriate debug JS file. I guess then I will need to build GN from source with a new .js include file?

Thanks again for all your help,

David.

________________________________
This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system.
________________________________

Hi,

As i told you, it has never been tested so code adjustements need to be
made.
Do you think you could submit a pull request with all steps we're going to
make to make it work ?

Historically, the projection loading should have been there :
https://github.com/geonetwork/core-geonetwork/blob/develop/web-ui/src/main/resources/catalog/components/common/map/mapService.js#L73

But i'm not sure the method importProj4js is called anymore.
It was originally done in this commit

Try to put it back.
Also, to test if your projection is loaded do a ol.proj.get('EPSG:3031' )
and see if it's null.

The other solution, is to edit the setting.js file and to add your
proj4.defs("EPSG:3031","+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1
+x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs");
proj4.defs("urn:ogc:def:crs:EPSG::3031","+proj=stere +lat_0=-90 +lat_ts=-71
+lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs");
in it.

On Wed, Jul 29, 2015 at 10:28 AM, Herbert, David J. <darb1@anonymised.com> wrote:

Hi Florent,

This was indeed helpful. I think I can now see what the problem is – GN
can’t load my context due to problems with the projection (in particular OL
transforming from Mercator to 3031). Looking at the traceback I now get
and using Chrome debugger to investigate further suggests that our CRS
EPSG:3031 isn’t understood natively by Proj4js. I have seen this in my own
OL applications for the Antarctic region. I have had to manually load a
3031.js defs file e.g:

proj4.defs("EPSG:3031","+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1
+x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs");
proj4.defs("urn:ogc:def:crs:EPSG::3031","+proj=stere +lat_0=-90
+lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs");

to ensure that Proj4js can do transforms etc. So it seems like a good way
forward might be to get GN to load this projection definition. I imagine I
can at least test this by adding the above lines manually to the
appropriate debug JS file. I guess then I will need to build GN from
source with a new .js include file?

Thanks again for all your help,

David.

________________________________
This message (and any attachments) is for the recipient only. NERC is
subject to the Freedom of Information Act 2000 and the contents of this
email and any reply you make may be disclosed by NERC unless it is exempt
from release under the Act. Any material supplied to NERC may be stored in
an electronic records management system.
________________________________

------------------------------------------------------------------------------
_______________________________________________
GeoNetwork-users mailing list
GeoNetwork-users@lists.sourceforge.net
geonetwork-users List Signup and Options
GeoNetwork OpenSource is maintained at
GeoNetwork - Geographic Metadata Catalog download | SourceForge.net

--
*camptocamp*
INNOVATIVE SOLUTIONS
BY OPEN SOURCE EXPERTS

*Florent Gravin*
0479444492

From https://github.com/geonetwork/core-geonetwork/commit/ea83ed020e7868d5c40120b368f0a46b41e53c84 I have done as requested. This is now at least throwing up some issues about finding the services that I have defined, so I think we have progress!

Thanks,

David.

From: Florent Gravin [mailto:florent.gravin@…137…]
Sent: 29 July 2015 11:40
To: Herbert, David J.
Subject: Re: [GeoNetwork-users] customizing the GN 3 map viewer

uncomment the code and add gnMap injection.
look the commit i gave to you for catController.js, and do exactly the opposite.

On Wed, Jul 29, 2015 at 12:36 PM, Herbert, David J. <darb1@...688...<mailto:darb1@…688…>> wrote:
Hi Florent,

Thanks for this. I’m having a bit of trouble understanding exactly what you’re asking me to do here. It does look like Proj4js is not called any more (looked in CatController.js within the installation, and indeed the line gnMap.importProj4js() is commented out, along with the comment “make map proj load in mapService.config instead of here”). A naïve approach of simply uncommenting this doesn’t work (I didn’t really expect It would!) as things are clearly done differently now.

What I don’t understand is that I’ve given the EPSG:3031 defs in the “list of CRS” within the admin console settings. This is exactly the same information as I would give Proj4js, were it being used. Why is the definition not picked up from here? I can see that the importProj4js() method sets some proj4.defs, but clearly it is no longer being called.

If I were to take your other solution of editing the setting.js file – can you let me know which file I need to edit as I can see a number of possibilities.

Many thanks,

David.

________________________________
This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system.
________________________________

--
camptocamp
INNOVATIVE SOLUTIONS
BY OPEN SOURCE EXPERTS

Florent Gravin
0479444492
________________________________
This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system.
________________________________