Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how do i add a new class to draw a plot of land in a polygon?

I’m trying to create a geographic information system, namely to add land ownership rights, by drawing a certain area, but what happens is not a drawing, but a map shift. Here for my script on models, below for pictures, models, and scripts that I use :
img

    <?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Sawah_model extends CI_Model {
  public function getAllSawah(){
    $this->db->select('f.id, f.color, f.landowner, f.crop, f.hamlet, f.planting_date, g.geo_type, g.coordinates');
    $this->db->from('field f');
    $this->db->join('geometries g', 'f.id = g.field_id');
    $q = $this->db->get();
    
    return $q->result();
  }

  public function addSawah(){
    $data = array(
      "color" => $this->input->post('color'),
      "landowner" => $this->input->post('owner'),
      "crop" => $this->input->post('crop'),
      "hamlet" => $this->input->post('hamlet'),
      "planting_date" => $this->input->post('planting_date')
    );
    $this->db->insert('field', $data);
    
    $last_id = $this->db->insert_id();
    $this->addSawahGeometry($last_id);
  }

  public function checkSawahByID($id){
    return $this->db->get_where('field', ['id' => $id])->num_rows();
  }

  public function getSawahByID($id){
    $this->db->select('f.id, f.color, f.landowner, f.crop, f.hamlet, f.planting_date, g.geo_type, g.coordinates');
    $this->db->from('field f');
    $this->db->join('geometries g', 'f.id = g.field_id');
    $this->db->where('f.id', (int)$id);
    $q = $this->db->get();
    
    return $q->row();
  }
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

have you ever tried anything like this before?
Try adding a new class like this:

private function addSawahGeometry($id_sawah){
    $data = array(
      "geo_type" => "Polygon",
      "coordinates" => $this->input->post('coordinates'),
      "field_id" => (int)$id_sawah
    );

    $this->db->insert('geometries', $data);
  }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading