Loading
  1. /* See if we are in a known field */
  2. SELECT trading_id INTO @trading_id_ FROM gts_hectare_birdseye_fields.tracker WHERE device_ID = NEW.deviceid LIMIT 1;
  3.  
  4. SET NEW.field_id = @trading_id_;
  5. SET lon =  NEW.longitude;
  6. SET lat = NEW.latitude;
  7. SET mystring = CONCAT('POINT(', lon , ' ', lat, ')');
  8. SET g = GeomFromText(mystring);
  9.  
  10. SELECT field_id, field_name INTO field_id_, field_name_ FROM gts_hectare_birdseye_fields.fields
  11. JOIN gts_hectare_birdseye_fields.farms ON gts_hectare_birdseye_fields.fields.farm_id = gts_hectare_birdseye_fields.farms.id_farm
  12. JOIN gts_hectare_birdseye_fields.trading_name ON gts_hectare_birdseye_fields.farms.trading_id = gts_hectare_birdseye_fields.trading_name.id_trading_name
  13. WHERE CONTAINS(FIELDS.geo_polygon, g) ORDER BY FIELDS.field_id DESC LIMIT 1;

Comments