Jump to:

10930 Posts in 2613 Topics by 1810 members

All other Modules

SilverStripe Forums » All other Modules » GIS Module Help

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1560 Views
  • te_chris
    Avatar
    Community Member
    24 Posts

    GIS Module Help Link to this post

    Hey guys,

    The web app i'm building needs pretty heavy geolocation features so i've turned to the GIS module. It installed fine and the points are available - when I declare a DBField a GeoPoint it comes up in PhpMyAdmin as a field type point, from there, however the behaviour gets weird. I'm using the class methods to set lat and lng but from what I can tell all it's actually setting is this "  Rew??F??sCSvPe@" weird unicode string, and not exhibitng the behaviour that the mysql docs say. I've tried using the setLat and setLng methods and as far as php is concerned they work, but then this is what gets set into the db. for now i'm just going to declare lat/lng number columns, but is there something i'm missing? is there a better way to do this? do you need code sample? is this module still supported?

    Thanks,
    Chris

  • te_chris
    Avatar
    Community Member
    24 Posts

    Re: GIS Module Help Link to this post

    just bumping in the hope that i'm not the only person to use this module

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: GIS Module Help Link to this post

    Haven't tried the module much myself and only then I used Postgres rather than MySQL but what happens if you manually set the GeoPoint in the database (eg via a UPDATE command). Does the data in the table display correctly? Could be an encoding issue perhaps? depending if your database is in UTF-8 or not.

  • wmk
    Avatar
    Community Member
    45 Posts

    Re: GIS Module Help Link to this post

    Hi te_chris,

    i'm, too, stuck with gis module atm.

    I can save to DB via GoogleGeocoder and it's aved as a "weird" string in DB, which is normal.

    A query like

    SELECT ID, AsText( Location ) FROM StandortPage

    returns the data human readable like

    ID    AsText(Location)
    17    POINT(13.621356 47.7132193)

    The problem is to get the data out of the database using DataObject ;)

    From what i found so far is that GeoDBField::addToSQL() is NOT called.

    It should be called in DataObject.php around line 2585

    if($compositeFields) foreach($compositeFields as $k => $v) {
    $dbO = $this->dbObject($k);
    if($dbO) $dbO->addToQuery($query);

    But $dbO is empty, maybe because $this is a SiteTree Object and not my Page Class containing the GeoPoint Definition?

    Any help appreciated. Maybe Ingo can put some light on this?

    Cheers, wmk

  • wmk
    Avatar
    Community Member
    45 Posts

    Re: GIS Module Help Link to this post

    I got it working so far - still quite untested but i'm happy i found a possible solution.

    In Dataobject.php around line 2585 i replaced the foreach loop with this construct:

    if($compositeFields) foreach($compositeFields as $k => $v) {
    $dbO = $this->dbObject($k);
    if($dbO) {
    $dbO->addToQuery($query);
    } else {
    $tableClassObject = new $tableClass;
    $dbO = $tableClassObject->dbObject($k);
    if($dbO) {
    $dbO->addToQuery($query);
    }
    }
    }

    So addToQuery() is finally called.

    Another bug was in GeoPointField.php::__construct(). The default value for $value was "" and should be null

    class GeoPointField extends FormField {
       public $xField, $yField;

       function __construct($name, $title = null, $value = null, $form = null) {

    HTH anyone ;)

    Cheers,

    wmk

  • te_chris
    Avatar
    Community Member
    24 Posts

    Re: GIS Module Help Link to this post

    Wow, thanks for the replies guys! I'm going to be working on this code this arvo so will reply with stuff shortly.

    1560 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.