I've been trying to import a POINTS based shapefile into Geospatial Data in Geo Module. I've tried using MySQL and PostgreSQL with PostGIS and have successfully imported POLYGON shapefiles with no problems. I've downloaded shapefiles from Census and have created shapefiles from scratch and I run into the same error.

user warning: Cannot get geometry object from data you send to the GEOMETRY field query: INSERT INTO geo_data_foopoint (statefp, countyfp, countyns, pointid, fullname, mtfcc) VALUES ('foo', 'foo', 'foo', 'foo', 'foo', 'foo') in /htdocs/drupal6/includes/common.inc on line 3477.

Could someone post a point shapefile that works on their system? I'm fairly sure I'm just doing something wrong. Thanks!

Comments

spelcheck’s picture

I just upgraded to latest dev and getting different messages now.

"Call to undefined geo operation schema_field" and immediately after that,

# warning: array_merge() [function.array-merge]: Argument #2 is not an array in /drupal6/sites/all/modules/geo/includes/shp2sql.inc on line 56.

# user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL ) /*!40100 DEFAULT CHARACTER SET UTF8 */' at line 2 query: CREATE TABLE geo_data_pointstest2 ( `geo` NOT NULL ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /drupal6/includes/database.inc on line 550.

# user warning: Table 'drupal6.geo_data_pointstest2' doesn't exist query: CREATE SPATIAL INDEX geo_data_pointstest2__geo_idx ON geo_data_pointstest2 (geo) in /drupal6/sites/all/modules/geo/includes/handlers/geo_sql_mysql.inc on line 64.

# user warning: Table 'drupal6.geo_data_pointstest2' doesn't exist query: INSERT INTO geo_data_pointstest2 () VALUES () in /drupal6/includes/common.inc on line 3477.

I'll keep digging, but please reply if anyone has a hint.

travismiller’s picture

I had this same issue with a POINTS shapefile. 6.x-1.0-alpha5

I traced back to shp2sql.inc:geo_shp2sql:

    // TODO NOT EFFICIENT
    $values['geo'] = db_result(db_query("SELECT GeomFromText('%s', %d)", $shp['data']['wkt'], $srid));

$shp['data'] is a string "POINT(#.### #.###)" instead of an array with 'wkt'.

I patched by testing if it was a string and treating it as such.

    // TODO NOT EFFICIENT
    if (is_string($shp['data'])) {
      $values['geo'] = db_result(db_query("SELECT GeomFromText('%s', %d)", $shp['data'], $srid));
    } else {
      $values['geo'] = db_result(db_query("SELECT GeomFromText('%s', %d)", $shp['data']['wkt'], $srid));
    }

I haven't traced back any further than this. My imports worked after this change. HTH