Have set up a simple Trackfield map to display lat and long points. If I edit an existing node, add the track data and then save when I re-enter the node in edit mode I find the Location module data no longer shows.

Have re-checked this on several existing nodes and found the same problem. The problem goes away after de-activating the Trackfield module, though I have to re-enter the Location module data.

Comments

jupiterchild’s picture

Version: 5.x-0.1 » 5.x-0.3

I should add I am using the latest version of the Location module 5.x-3.x-dev 2008-07-26

raintonr’s picture

Are you entering some trackfield data with lat/lon points? The trackfield module is meant to set a node's location to the centre of any track entered.

jupiterchild’s picture

I'm uploading a csv file (into Trackfield) containing only lat/lon coordinates.

I also have a CCK + Gmap View + Node Reference providing a map taking lat/lon coordinates from the Location module. It is this data which disappears from the Location module form after inserting Trackfield data. I'm no expert on mapping or coding but presumably the Location data must still be in the database or the 'Location' map would revert to a default map view.

Example of how I am using mapping:
http://neiljacklin.com/cms/2008/06/23/uk/derbyshire/longshaw-estate/uppe...

BTW just to avoid confusion the 'Location' tab (first of a set of tabs) on this site is nothing to do with the Location module, it is text based + a KML link to Google earth.

BTW I have only just come across this great module which is exactly what I need for parts of my site.

raintonr’s picture

Nice site... :)

So what have you configured for 'Locative information' for this content type? I assume you have just added one trackfield CCK field and the trackfield_map for display. Is that distance underneath coming from a trackfield_stats field?

Then when you enter data you put in the path co-ords and also manually put in the location? Which in your example happens to be the start/finish.

Firstly I think you'd like an option to put the auto-location at the start/finish rather than 50% of the way round the path?

How has this node come to have it's location shown in this way if you say the trackfield is clearing that location?

jupiterchild’s picture

A few answers to #4

Content Type config >> Locative information >> Number of locations

Maximum number of locations allowed for this type: = 1
Default number of location forms: = 1

CCK Trackfield config

Route Map group_track_map group
Track field_track Track
Track Map field_track_map Track Map
Track Statistics field_track_stats Track Stat

Trackfield node config

Track Statistics: empty
Track: trackfield-nid6031.csv (this is just the csv output from a MemoryMap application track with everything except lat/lon points stripped out)
Treat data as: File: Lat,Lon,Usr...

Yes, the distance underneath the map is coming from the field_track_stats

The start / finish marker is in the correct position on the example node.

I only use the Location module to provide the lat/long for the the gmap_location module and because I didn't like the Location module output (which you can choose not to display) I created some CCK text fields and just manually copied the lat/lon data from the Location data. I then trawled through several hundred nodes and manually added all the Location data and then a couple of weeks later someone produced the CCK Lat/Lon Module but no way was I trawling through all the nodes again! It's a little confusing, the tab marked Location (on the example node) is actually CCK text fields manually filled out with lat/lon and description data. The actual Location module is not displaying data in the example node, but it is the Location module node input form that loses the data when I edit the node that contains Trackfield data.

If I get some time this weekend I will send some screen shots, this could probably better describe the problem. Meanwhile I will experiment a little more to see if I get get a handle on the problem.

I see great potential in Trackfield and am very grateful for your hard work. I may try and write a few notes for newbies like me since it took me a while to figure out all the bits and pieces. In fact I shied away from it for a while since it looked rather complicated though in actual fact it is very easy to use.

jupiterchild’s picture

StatusFileSize
new129.54 KB
new113.52 KB
new116.83 KB

raintonr

Attachment trackfieldissue01.jpg shows the location table with Trackfield module deactivated.

Attachment trackfieldissue02.jpg shows the location table with Trackfield module activated and after editing a node.

I notice that the LID field value changes each time the edited node is saved. The actual LAT and LON field data is not lost, just the Name, Country fields etc.

Attachment trackfieldissue03.jpg shows the node edit form for the example node I gave you.

I have spent some time looking through the issues for Location module but the only issue I could see that may help was this (though I must admit don't fully understand it):
http://drupal.org/node/287216
I applied the provided patch but the problem persists.

jupiterchild’s picture

Played around with this problem some more and realised:

Trackfield Module being active is not a problem. I can edit nodes and the Location Module retains its data. It is ONLY when valid data is entered into the Track data field and the node is saved that the ALL Location form data is lost, though the Location database table still shows data in the LAT and LON fields but the Name, Country etc. fields are empty.

jupiterchild’s picture

I have looked at this issue again:

In Location 3 module it is now possible to change the weighting in Content Type > Locative Information > Collection Settings, doing so does not change this issue but I now notice 'Array' appearing in the Location box input form.

jupiterchild’s picture

raintonr

Now using v5.x-0.4

If in the trackfield.module I comment out this section of code then the Location data problem goes away. I'm not sure what this section of code does, but Track, Track_csv, Track_map and Track_stats all seem to work as before.

      /*
       * If the location module is in use and number of locations per
       * node of this type > 0 and we have been given longitude/
       * latitude (which implies distance should also be here).
       * Calculate which point closest to the centre of this track
       * and mark this node at that location.
       */
      /* TODO: Make this a parameter */
      /* TODO: Handle multiple locations & fields */

#      if (module_exists('location') &&
#          variable_get('location_maxnum_'. $node->type, 0) > 0) {
#        /* Find a field with lat/lon data */
#        foreach (_trackfield_fields() as $field) {
#          $fset = $node->$field;
#          if (is_array($fset)) {
#            foreach ($fset as $item) {
#              if (array_key_exists('longitude', $item) &&
#                array_key_exists(de', $item)) {
#              /* Find the point nearest the centre */
#                $dsta = $item['distance'];
#                $halfway = $dsta[count($dsta) - 1] / 2;
#                for ($lp = 0; $lp < count($dsta) && $dsta[$lp] < $halfway; $lp++) {
#                  /* Do nothing - we're just looking for the middle */
#                }
#                $node->locations[0] = array(
#                  'longitude' => $item['longitude'][$lp],
#                  'latitude' => $item['latitude'][$lp]
#                );
#              }
#            }
#          }
#        }
#      }
#      break;
raintonr’s picture

Thanks for your digging here. As the comment above it says, this section is supposed to set a number of location points for a node, at the the centre of any track(s) entered.

I can't imagine that anyone would want to manually add location information to a node with trackfield data on. However, by the sound of it that is exactly what you are doing - may I ask why?

Perhaps this should become an option for the trackfield widget in question: "Create location information for the node from this field?"

Basically this sounds like it's by design right now.

jupiterchild’s picture

In the dark and distant Drupal past the only way of setting lat/lon coordinates was by using the Location module. From what I can remember unless you were building a map manually with gmap macro then gmap_location and gmap_cck relied on Location for lat/lon data. I was (and still am) using the lat/lon coordinates to fix the location of where my thumbnail image for each node was taken. Hence ALL my nodes have Location module lat/lon cordinates and in future other geo info may be entered. Location module together with gmap_location also provides a global view of where each article (node and/or user) is located. Over the last 18 months location and mapping have really moved on (witnessed by your own fine module) but in some cases one is stuck with legacy. Along comes Google Earth and the KML module (which I think you have been helping with) and the Location module itself is undergoing much improvement and quite often it is difficult to know what to run with except in the case of your module which does exactly what I require. I regret that I am not a coder and not really able to help on that side but I will continue to try and help debug.

I think where my usage is slightly confusing is that I am logging both the lat/lon of photographs and lat/lon points on routes/tracks but not always in the same node which is why I found the above section of code a little confusing, since it could be not everyone will be using the Location module just to provide lat/lon coordinates in the way anticipated.

Once again thanks for your fine modules and help, now to try and find why track_graph fails on my site :)

raintonr’s picture

I can see where you're coming from. Indeed, it may be a pain that the trackfield replaces location information.

As the code says, the way forward is for this to become a parameter, how best to do that though?

Thinking today perhaps the the answer is to make this an option at the widget level. If you agree this is a good idea will try and introduce the following:

On the 'Widget settings' part of the trackfield base field there is currently just the 'Normalise As:' option. Introduce a second option which is 'Use track co-ordinates to overwrite location information for this node where possible:'.

That way, users such as yourself, who do not want to have location set with the trackfield can set this to 'No' for all their widgets, and I can leave it as 'Yes'.

Does that sound like a good solution?

P.S. I've already considered that some users will not want to have location set at the centre point of a trackfield, this option may be added in the same place later.

jupiterchild’s picture

That solution would certainly work for me.

Having commented out that section of code I have been able to add some more tracks and play around with various settings without losing the Location details for my photographs, but being able to configure a parameter in a widget would provide the perfect solution.

To be honest having to use Location module, in my case for just providing a single lat/lon point, is a bit of a pain because Location3 now has all the geolocation stuff together with country and post codes and is quite a large install but what is important is to be able to retain my existing lat/lon coordinates, since as I said, this is legacy and I would need to change 500+ nodes.

BTW I am very aware of your statement "BETA code - test thoroughly in development/test systems prior to deploying!" so I don't expect everything to work immediately nor do I expect instant support. I see great potential in what you are doing in what I suppose is rather a 'niche market' so I will follow your developments with anticipation.

I am finding your test site very useful because if my data works there then I can start trying to figure why it won't work elsewhere.

raintonr’s picture

Status: Active » Fixed

Fixed with this:

http://drupal.org/cvs?commit=133616

Each trackfield widget now has an option to specify if it should overwrite location information using co-ordinates given in that field. If all trackfield instances are left as 'No' then no changes to location information will be made as per this bug request.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.