Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-4759

OPENGIS - artificial (not oficial) support to circle

    XMLWordPrintable

Details

    • Task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Won't Fix
    • None
    • None

    Description

      opengis is very nice, but we don't have a CIRCLE (ok it's mercator and blablabla), maybe we could use a circle->polygon converter.... example:

      polygonfromtext("CIRCLE(10 20 30)")

      could return a circle with radius 10, center point(20,30)
      we could add a variable (a variable that should be placed in query cache flags or a global variable that should be used in replications) @@opengis_circle_points=360

      we will do something like... (cos and sin are degree not radian)

      for(i=0;i<360;i+=360/@@opengis_circle_points)
         poligon point to (x=center+cos(i)*radius, y=center+sin(i)*radius)
      poligon point to (x=center+cos(360)*radius, y=center+sin(360)*radius)

      with this we create a poligon in each circle point
      it's a nice feature since many code is done at client side and we could put it in server side

      this function could return something like:

      polygon(x0 y0, x1 y1, x2 y2 ... x360 y360)   where 0=0degree,1=1degree..360=360degree)

      i didn't read the mariadb gis source yet, but i think it's a easy function
      we will not save circle, just polygons
      javascript (using gmaps)

      	function drawCircle(lng,lat,kmRadius) {
      		var Cradius = 1;		// km radius
      		var Ccolor = '#0000ff';		// color blue
      		var Cwidth = 3;			// width pixels
      		var d2r = Math.PI/180;		// degrees to radians
      		var r2d = 180/Math.PI;		// radians to degrees
      		var Clat = (kmRadius/6378.8)*r2d;   //  using 6378.8 as earth's radius
      		var Clng = Clat/Math.cos(lat*d2r);
      		var Cpoints = [];
      		var i, theta, Cx, Cy;
      		var npoints=33;
      		for (i=0; i < npoints; i++){
      			theta = Math.PI * (i/Math.floor(npoints/2));
      			Cx = lng + (Clng * Math.cos(theta));
      			Cy = lat + (Clat * Math.sin(theta));
      			Cpoints.push(new GLatLng(Cy,Cx));
      		}
      		map.addOverlay(new GPolyline(Cpoints,Ccolor,Cwidth));
      	} 

      Attachments

        Activity

          People

            Unassigned Unassigned
            rspadim roberto spadim
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.