1 (edited by Alan Hale 03-02-2010 21:04:03)

Re: My Dot Map Drupal iForm

I've just tried to create an Indicia form of type "My dot map" and get the error:

* warning: Invalid argument supplied for foreach() in /var/www/vhosts/wales-lichens.org.uk/httpdocs/apprentices/sites/all/modules/iform/iform.module on line 372.
       * warning: Invalid argument supplied for foreach() in /var/www/vhosts/wales-lichens.org.uk/httpdocs/apprentices/sites/all/modules/iform/client_helpers/prebuilt_forms/includes/map.php on line 127.
    * warning: Invalid argument supplied for foreach() in /var/www/vhosts/wales-lichens.org.uk/httpdocs/apprentices/sites/all/modules/iform/client_helpers/prebuilt_forms/my_dot_map.php on line 292.

Firebug reports:

maxExtent is null
http://.........../iform/media/js/OpenLayers.js?K
Line 840

I'm sure I've entered all the required map parameters
Alan

Alan Hale
Aberystwyth

2

Re: My Dot Map Drupal iForm

Hi Alan

Hmm, are you sure you have ticked one of the preset base layers in the Base Map Layers section? That would explain the 2nd error and the mapExtent error, although Drupal's validation is supposed to prevent you doing this.
The error on line 292 in my_dot_map is because this iForm is designed to be displayed as a redirection after saving a record. As you are displaying it directly it has no information about the record to display data for. I've just made a tweak to the code so that it doesn't error in this circumstance though. To fix it, open my_dot_map.php and look for line 288. Change

  // Now output a grid of the occurrences that were just saved.
  $r = '<div class="page-notice ui-widget ui-corner-all">';
  $r .= "<table><thead><tr><th>Species</th><th>Date</th><th>Spatial Reference</th></tr></thead>\n";
  $r .= "<tbody>\n";      
  foreach ($occurrence as $record) {
      $r .= "<tr><td>".$record['taxon']."</td><td>".$record['date_start']."</td><td>".$record['entered_sref']."</td></tr>\n";
  }
  $r .= "</tbody></table>\n";
  $r .= data_entry_helper::map_panel($options);
  return $r;

to

    // Now output a grid of the occurrences that were just saved.
    if (isset($occurrence)) {
      $r = '<div class="page-notice ui-widget ui-corner-all">';
      $r .= "<table><thead><tr><th>Species</th><th>Date</th><th>Spatial Reference</th></tr></thead>\n";
      $r .= "<tbody>\n";      
      foreach ($occurrence as $record) {
        $r .= "<tr><td>".$record['taxon']."</td><td>".$record['date_start']."</td><td>".$record['entered_sref']."</td></tr>\n";
      }
      $r .= "</tbody></table>\n";
    }
    $r .= data_entry_helper::map_panel($options);
    return $r;

The other point is that my_dot_map is set up at the moment to use a GeoServer installation to draw the maps, which I don't think you have at the moment. I guess a nice enhancement would be to allow maps to be drawn using occurrences obtained via the Indicia Warehouse data services, which will be a little slower but it should work fine as long as there aren't too many points to draw. Sounds like a job for someone...

Cheers

John van Breda
Biodiverse IT

3 (edited by Alan Hale 04-02-2010 10:43:20)

Re: My Dot Map Drupal iForm

Thanks John - I've got a lot to learn about how all this works.

I'm sure I did enter a base layer - as you say, Drupal complains if you don't.

I changed the code as you suggested, but get similar errors from elsewhere:

warning: Invalid argument supplied for foreach() in /var/www/vhosts/wales-lichens.org.uk/httpdocs/apprentices/sites/all/modules/iform/iform.module on line 372.
warning: Invalid argument supplied for foreach() in /var/www/vhosts/wales-lichens.org.uk/httpdocs/apprentices/sites/all/modules/iform/client_helpers/prebuilt_forms/includes/map.php on line 127
It's probably not worth me pursuing this until I've got a better understand of how this form should be used.

Geoserver - I have geoserver installed and up and running, and referenced in my config files,  but I don't really understand how it works with  Indicia. Is there some documentation?

Thanks again.

Alan

Alan Hale
Aberystwyth

4

Re: My Dot Map Drupal iForm

Hi Alan

Have you used GeoServer before? I had uploaded some rough notes on what needs to be done as a default setup for Indicia to http://code.google.com/p/indicia/wiki/T … gGeoServer but they were really just intended to remind me what needs to be done when I write the tutorial. If you can work out how to create a data store for your Indicia database, then expose the detail_occurrences view as a feature type, setup the style as in the Wiki page, you will be well on the way.

Cheers

John van Breda
Biodiverse IT

5

Re: My Dot Map Drupal iForm

Hi John

No, I've never used Geoserver before and have only had a brief look at it's capabilities (since I've been working with Indicia). I'll investigate along the lines you've suggested.

Cheers

Alan

Alan Hale
Aberystwyth

6

Re: My Dot Map Drupal iForm

If you get stuck let me know, it's pretty easy once you know how to use it. In return could you keep some notes so we can update the Wiki tutorial?

John van Breda
Biodiverse IT

7 (edited by Alan Hale 06-02-2010 23:21:18)

Re: My Dot Map Drupal iForm

OK, I'm pretty excited now because I've learnt to expose detail_occurrences as a layer in Geoserver and I've just managed to work out how to  display tha tLayer  in Google Earth via a Network Link.

But how do I connect the Geoserver layer to my_dot_map in Drupal?

Cheers

Alan

Alan Hale
Aberystwyth

8

Re: My Dot Map Drupal iForm

Hi Alan,

In the IForm module folder, find client_helpers/helper_config.php and open it in an editor. The setting for $geoserver_url needs to point to your GeoServer root instance. In my local case it is

  static $geoserver_url = 'http://localhost:8080/geoserver/';

.

Now, create a content page using the Indicia Forms content type, and select My dot map as the form. Go through the parameters, making sure you select at least one preset base layer. Here are the settings I used to set up a layer that shows the occurrences in the same survey that the record just saved was in:
Layer Caption: Occurrences in this survey
Layer 1 uses GeoServer to access Indicia database? - ticked
Layer Name: indicia:detail_occurrences (depends on the feature type and prefix you set up)
What to filter against: Survey
Style: dist_point_red (or whatever style name you want)

Now, save this page and note the path. In your data entry form, specify this as the URL to redirect to after saving a record. Then when the user saves a record, it will show a map of all points in the survey, plus a grid summarising the just entered data.

Have fun,

John van Breda
Biodiverse IT

9

Re: My Dot Map Drupal iForm

Hi John

Thanks for this. I've given it a go but still get a similar error to that I had originally:

* warning: Invalid argument supplied for foreach() in /var/www/vhosts/wales-lichens.org.uk/httpdocs/apprentices/sites/all/modules/iform/iform.module on line 372.
    * warning: Invalid argument supplied for foreach() in /var/www/vhosts/wales-lichens.org.uk/httpdocs/apprentices/sites/all/modules/iform/iform.module on line 372.
    * warning: Invalid argument supplied for foreach() in /var/www/vhosts/wales-lichens.org.uk/httpdocs/apprentices/sites/all/modules/iform/client_helpers/prebuilt_forms/includes/map.php on line 127.

and Firebug reporting that maxExtent is null

I'm pretty sure I've entered everything as required but I'll send you a couple of screenshots separately so that you can check.
Cheers

Alan

Alan Hale
Aberystwyth

10

Re: My Dot Map Drupal iForm

Hi Alan

It looks like what is being stored in the Drupal database for your IForms is not quite right. The method which reads out the parameters ready to build the form is reporting is not decoding the stored data correctly. Can you edit your iform.module file please, and add an echo into the iform_load method so it looks like the following:

function iform_load($node) {
  $t = db_fetch_object(db_query('SELECT iform, params FROM {iform} WHERE nid = %d', $node->nid));
  $params=json_decode($t->params);
  unset($t->params);
  echo '<pre>'.print_r($params, true).'</pre>';
  // Merge the params into the loaded object
  foreach($params as $k => $v) $t->$k = $v;
  return $t;
}

Then let me know what it adds to the top of the page (or just email me the URL).

Cheers

John van Breda
Biodiverse IT

11

Re: My Dot Map Drupal iForm

Hi John

I've added in the echo as requested but when I do a Save  there is no output on the page other than the original error message and the page introductory text. The parameters I've entered to the form do not get saved either - if I open for editing they have disappeared from the input fields.

http://www.wales-lichens.org.uk/apprentices/content/display-lichen-records

Cheers

Alan

Alan Hale
Aberystwyth

12

Re: My Dot Map Drupal iForm

I've fixed some problems in the iForm module when saving after a validation failure, see http://code.google.com/p/indicia/issues … p;sort=-id.

John van Breda
Biodiverse IT

13

Re: My Dot Map Drupal iForm

John - I've pulled down the latest versions from Subversion and installed them - but I still get the same errors.

The problems start as soon as I select the My Dot Map form type, with this error:

warning: Invalid argument supplied for foreach() in /var/www/vhosts/wales-lichens.org.uk/httpdocs/apprentices/includes/form.inc on line 1206.

and then if I continue to enter the form parameters and save:

* warning: Invalid argument supplied for foreach() in /var/www/vhosts/wales-lichens.org.uk/httpdocs/apprentices/sites/all/modules/iform/iform.module on line 372.
    * warning: Invalid argument supplied for foreach() in /var/www/vhosts/wales-lichens.org.uk/httpdocs/apprentices/sites/all/modules/iform/client_helpers/prebuilt_forms/includes/map.php on line 127.

As before, Firebug reports maxExtent is null

Cheers

Alan

Alan Hale
Aberystwyth

14

Re: My Dot Map Drupal iForm

Hi Alan

I've hada  quick look at your site via FTP, and you still have the old iform.module file on the site. The latest version in Subversion has the following method at the end:

function iform_form_alter(&$form, $form_state, $form_id) {
  if ($form['#type']=='iform') {
    // Set the right #action
    if (!empty($form['nid']['#value'])) {
      $form['#action'] = url('node/'.$form['nid']['#value'].'/edit');
    }
    else {
      $form['#action'] = url('node/add/iform');
    }
  }
}

Regards

John van Breda
Biodiverse IT

15

Re: My Dot Map Drupal iForm

Sorry John - it was getting late last night.

I have now copied the correct version over but still get the same error. I haven't got time to check for any other obvious blunders on my part at the moment - I'll go over it tonight.

Cheers

Alan

Alan Hale
Aberystwyth

16

Re: My Dot Map Drupal iForm

Something odd going on here as it does not want to save your custom parameters but it is definitely working OK for me now. If you have phpMyAdmin installed (or similar), can you check the content of the iform table please in your Drupal database? Just the values for the dot map you have created will do. It should have fields called nid, iform and params.
Thanks,

John van Breda
Biodiverse IT

17 (edited by Alan Hale 10-02-2010 15:47:27)

Re: My Dot Map Drupal iForm

Hi John

I thought I'd discovered the problem because the params field seems too short at 255 to hold all the info, and it gets truncated. However I upped the length to 1000 (500 still wan't long enough) and I think all the parameters are now stored - but I still get the same error. And the parameters aren't recovered when I go to edit a form.

But you say this works when you create a form on my site?

I'll email you my last parameters list - they seem to get truncated when I paste in here.

Cheers
Alan

Alan Hale
Aberystwyth

18 (edited by Alan Hale 10-02-2010 15:55:01)

Re: My Dot Map Drupal iForm

.. and I've just realised even 1000 isn't enough. I've gone crazy and set the length to 2000 - and now it works!!!

Although, still when I choose the form type My Dot Map from the drop-down list I still get:

warning: Invalid argument supplied for foreach() in /var/www/vhosts/wales-lichens.org.uk/httpdocs/apprentices/includes/form.inc on line 1206.

Regards

Alan

Alan Hale
Aberystwyth

19

Re: My Dot Map Drupal iForm

Hi Alan

Ah, I see. Mine was 2000, and it is 2000 in the SVN code but I think this was upped a few months ago. So I think the problem is that you originally installed the old version but the upgrade path did not work properly.

The other warning is something I have seen myself but with no apparent side effects. I will add it to the issues list and look into it.

Cheers

John

John van Breda
Biodiverse IT

20

Re: My Dot Map Drupal iForm

Ah - that's probably because I forgot to run update.php after updating the module. Duh!

Alan

Alan Hale
Aberystwyth

21

Re: My Dot Map Drupal iForm

We got some problems with the My Dot Map. Even following the instructions above its still not showing our detail_occurrences in the map. In the Distribution Map it does.

The Preview of the My Dot Map shows an error message:

  An error occurred when the data was submitted.
  Unknown Exception: unauthorised


Any suggestions?

thanks,
gaby