Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on geo-enabled tables #1

Open
eczajk1 opened this issue Mar 14, 2017 · 0 comments
Open

Error on geo-enabled tables #1

eczajk1 opened this issue Mar 14, 2017 · 0 comments
Labels

Comments

@eczajk1
Copy link
Contributor

eczajk1 commented Mar 14, 2017

It is not safe to do this type of thing for "geo enabled" fields, because "enabled" means that latitude longitude might not be provided:

hooks: {
    afterValidate: function (rep_surface, options) {
      rep_surface.the_geom = sequelize.fn('ST_SetSRID', sequelize.fn('ST_MakePoint', rep_surface.longitude, rep_surface.latitude), '4326');     },
  }

Need to either include an if statement for all "geo enabled" tables, or include only for tables where "geo enabled" but not "geo required":

hooks: {
  afterValidate: function (rep_surface, options) {
    if (rep_surface.longitude && rep_surface.latitude) {
      rep_surface.the_geom = sequelize.fn('ST_SetSRID', sequelize.fn('ST_MakePoint', rep_surface.longitude, rep_surface.latitude), '4326');
    }
  },
}
@eczajk1 eczajk1 added the bug label Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant