Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

arunraj2308
New Contributor

Point inside or outside given area

Hi All,

This is my second attempt at asking the same question. In my first attempt (Points In Polygon), I do not think I was able to explain the problem properly. Apologies. So here I go again ...

I am provided with area co-ordinates and using QV I need to show if customers fall inside or outside this area.

Area:
load * inline
[Area_X,Area_Y
0,0
4,0
2,2
4,4
0,4
0,0
];


Customer:
Load * inline
[Customer_ID, Cust_X, Cust_Y
1000001,1,3
1000002,3,2
];


Desired Result :
[Customer_ID, Cust_X, Cust_Y, Inside_Outside_Indicator
1000001,1,3, Inside
1000002,3,2, Outside
];

Please let me know if you need any further information. Any help will be greatly appreciated.

PS: I don't know if I need to use (or how to use) linest_m and linest_b to work out the line equation between points.

Kind Regards

Arun

1 Solution

Accepted Solutions
Or
Valued Contributor II

Re: Point inside or outside given area

I think it might be a tad optimistic to try and create a ray-casting algorithm on the fly in QlikView.

If you're OK with doing it script-side, you should be able to adapt the algorithms listed here:

https://rosettacode.org/wiki/Ray-casting_algorithm

Or better yet, calculate it at the database level, depending on your database:

oracle - Ray Casting With Pl/SQL Function - Stack Overflow

https://stackoverflow.com/questions/7573881/mysql-implementation-of-ray-casting-algorithm

4 Replies
Or
Valued Contributor II

Re: Point inside or outside given area

I think it might be a tad optimistic to try and create a ray-casting algorithm on the fly in QlikView.

If you're OK with doing it script-side, you should be able to adapt the algorithms listed here:

https://rosettacode.org/wiki/Ray-casting_algorithm

Or better yet, calculate it at the database level, depending on your database:

oracle - Ray Casting With Pl/SQL Function - Stack Overflow

https://stackoverflow.com/questions/7573881/mysql-implementation-of-ray-casting-algorithm

arunraj2308
New Contributor

Re: Point inside or outside given area

Thanks for the quick response Or Shosham.

I will try doing it at database level and let you know how it goes. I have a SQL Server 2014 database.

Kind Regards

Arun

arunraj2308
New Contributor

Re: Point inside or outside given area

Hi Or Shosham,

It's working !!


Thanks a million!

ajeanjot
New Contributor

Re: Point inside or outside given area

Hi,

I have the same issue in my project.

Could you give us an example of how you implemented it in your application ?

Thanks in advance.