Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

GIS Module Help


Go to End


6 Posts   2539 Views

Avatar
te_chris

Community Member, 24 Posts

20 September 2010 at 5:11pm

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

Avatar
te_chris

Community Member, 24 Posts

22 September 2010 at 9:41am

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

Avatar
Willr

Forum Moderator, 5523 Posts

22 September 2010 at 7:19pm

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.

Avatar
wmk

Community Member, 87 Posts

23 September 2010 at 4:03am

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

Avatar
wmk

Community Member, 87 Posts

23 September 2010 at 9:19pm

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

Avatar
te_chris

Community Member, 24 Posts

24 September 2010 at 12:42pm

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