Point inside polygon and distance point to polygon
Posted: April 8th, 2019, 10:31 pm
Dear Cspro Developer Team,
Maybe i'm the CSProuser who request more functionalities and features to you, and since you're a small team with limited ressources, it's impossible to respond to all CSProusers request. Latest weeks i'm trying to do my best to implement some functionalities such as Point inside polygon and distance point to polygon, this using the CSPro Programming Language. But, also, since i'm a Agricultural economics engineer, i'm limited in programming. I learned C/C++ at bachelor degree, years ago.
This would be worse if i used CAPI systems who don't have any code editor, compiler and don't supporting any know programming language.
Fortunately, CSPro Programming Language helped me to maintain a certain level in programming, mainly with your incredible support. And also, i realize that, if i spend more time to design advanced function in CSPro Logic, rather than waiting to you this will help me a lot in advanced programming. Also, the community will have access to them. However, since CSPro logic doesn't support object programming, such as Python or R, it limit us...
Following my early year post: http://csprousers.org/forum/viewtopic.php?f=1&t=2858, i would like to implement some algorithms from:
a.- http://geomalgorithms.com
b.- https://stackoverflow.com/questions/924 ... de-polygon
in CSPro Logic.
For this 2D polygon, i would like to:
a.- transform it in point (there's a lot of tools to to that in QGIS and the attribute table of points can be exported to Excel);
store these points in CSdb in a table having a table named polygon with 4 columns: pk_number, polygon_id, X, Y (i hope CSdb and Excel2CSPro will
support stored in multiple tables and columns soon. Normally, i can load the Excel-CSV file in an independent sqlite database, since Josh discourage to create other table in CSdb or CSlog, but i don't know how to synchronize an independent sqlite database to CSWeb..., so i maintain using CSdb);
b.- sync this CSdb to CSweb;
c.- using this CSdb in CSEntry application as external dictionary;
d.- using sqlquery to retrieve theses points as a numeric array : Does CSPro support array with decimal? In Javascript, it's easy:
https://stackoverflow.com/questions/703 ... javascript.
e.- the point that i want to know if it's inside the polygon is this recorded in CSEntry (application or in paradata).
f.- it's possible to transform this array of polygon in a object or similar element in CSPro logic? It's possible to implement this algorithm in CSPro logic:
(algorithm from: http://geomalgorithms.com )
Also can you advise me on better idea to do this?
Thanks in advance for your support!
Maybe i'm the CSProuser who request more functionalities and features to you, and since you're a small team with limited ressources, it's impossible to respond to all CSProusers request. Latest weeks i'm trying to do my best to implement some functionalities such as Point inside polygon and distance point to polygon, this using the CSPro Programming Language. But, also, since i'm a Agricultural economics engineer, i'm limited in programming. I learned C/C++ at bachelor degree, years ago.
This would be worse if i used CAPI systems who don't have any code editor, compiler and don't supporting any know programming language.
Fortunately, CSPro Programming Language helped me to maintain a certain level in programming, mainly with your incredible support. And also, i realize that, if i spend more time to design advanced function in CSPro Logic, rather than waiting to you this will help me a lot in advanced programming. Also, the community will have access to them. However, since CSPro logic doesn't support object programming, such as Python or R, it limit us...
Following my early year post: http://csprousers.org/forum/viewtopic.php?f=1&t=2858, i would like to implement some algorithms from:
a.- http://geomalgorithms.com
b.- https://stackoverflow.com/questions/924 ... de-polygon
in CSPro Logic.
For this 2D polygon, i would like to:
a.- transform it in point (there's a lot of tools to to that in QGIS and the attribute table of points can be exported to Excel);
store these points in CSdb in a table having a table named polygon with 4 columns: pk_number, polygon_id, X, Y (i hope CSdb and Excel2CSPro will
support stored in multiple tables and columns soon. Normally, i can load the Excel-CSV file in an independent sqlite database, since Josh discourage to create other table in CSdb or CSlog, but i don't know how to synchronize an independent sqlite database to CSWeb..., so i maintain using CSdb);
b.- sync this CSdb to CSweb;
c.- using this CSdb in CSEntry application as external dictionary;
d.- using sqlquery to retrieve theses points as a numeric array : Does CSPro support array with decimal? In Javascript, it's easy:
https://stackoverflow.com/questions/703 ... javascript.
e.- the point that i want to know if it's inside the polygon is this recorded in CSEntry (application or in paradata).
f.- it's possible to transform this array of polygon in a object or similar element in CSPro logic? It's possible to implement this algorithm in CSPro logic:
(algorithm from: http://geomalgorithms.com )
Code: Select all
//===================================================================
// wn_PnPoly(): winding number test for a point in a polygon
// Input: P = a point,
// V[] = vertex points of a polygon V[n+1] with V[n]=V[0]
// Return: wn = the winding number (=0 only when P is outside)
int
wn_PnPoly( Point P, Point* V, int n )
{
int wn = 0; // the winding number counter
// loop through all edges of the polygon
for (int i=0; i<n; i++) { // edge from V[i] to V[i+1]
if (V[i].y <= P.y) { // start y <= P.y
if (V[i+1].y > P.y) // an upward crossing
if (isLeft( V[i], V[i+1], P) > 0) // P left of edge
++wn; // have a valid up intersect
}
else { // start y > P.y (no test needed)
if (V[i+1].y <= P.y) // a downward crossing
if (isLeft( V[i], V[i+1], P) < 0) // P right of edge
--wn; // have a valid down intersect
}
}
return wn;
}
//===================================================================
Thanks in advance for your support!