Skip to content

Error on geo-enabled tables #1

@eczajk1

Description

@eczajk1

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');
    }
  },
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions