Giter VIP home page Giter VIP logo

cartodb's Issues

insert error with geojson

The following code:

   if (normalized.paths) {
    let geojson = {
      type: 'MultiLineString',
      coordinates: normalized.paths
    };
    normalized.the_geom = db.raw(`ST_GeomFromGeoJSON('${JSON.stringify(geojson)}')`);
    delete normalized.paths;
  }

  return db('appgeo_surveys')
    .insert(normalized)
    .then(() => {
      return data;
    });

Returns the following sql (via query.toString()):

BEGIN;
PREPARE _2c97d7a66be43fe4 AS
insert into "appgeo_surveys" ("is_correct", "issue", "comments", "confidence", "neighborhood_id", "city_id", "user_id", "the_geom") values ($1, $2, $3, $4, $5, $6, $7, $8);
EXECUTE _2c97d7a66be43fe4(false,$cartodb$boundaries little off$cartodb$,$cartodb$ewrwer$cartodb$,$cartodb$very$cartodb$,$cartodb$prt023$cartodb$,$cartodb$portland$cartodb$,$cartodb$1$cartodb$,$cartodb${"client":{"url":"urlobfuscated","key":"keyobfuscated","isBatch":false},"sql":"ST_GeomFromGeoJSON('{\\"type\\":\\"MultiLineString\\",\\"coordinates\\":[[[-122.66329765319824,45.60052733338059],[-122.66029357910158,45.60160825936073],[-122.65771865844728,45.60220876479576],[-122.65583038330078,45.60226881498576],[-122.65437126159667,45.60190851288167],[-122.65308380126955,45.60184846230603],[-122.65222549438475,45.60190851288167],[-122.65188217163086,45.602028613840126]],[[-122.68106460571289,45.60407029079811],[-122.67926216125487,45.60389014581998],[-122.67797470092772,45.60364995161597],[-122.67788887023924,45.60340975638357],[-122.67754554748535,45.60310951089689]]]}')","_noTransaction":false}$cartodb$);;
COMMIT;

notice the escaped double-quotes in the sql's geojson string, not sure if this is an issue

the error is

Error: {"error":["parse error - invalid geometry"],"hint":"\"{\"\" <-- parse error at position 2 within geometry"}

I've tried a variety of ways to represent the value, like db.raw('?', [...]) and db.raw(`ST_GeomFromGeoJSON('?')`, [..]), etc..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.