I use FSL.PolygonUtils from Field service package, to check if a latitude/longitude is within a service territory.

I want to separate my territories with record types. The problem is that API doesn't support it, as it give me back the closest territory level without considering record types(I can have overlapping territories, so that's why i user record type based on the request).

I am doing this query, to check all the territory where that coordinate could land :

SELECT Id, Name, FSL__Description__c, FSL__Color__c, FSL__KML__c, FSL__Service_Territory__c, FSL__Service_Territory__r.FSL__TerritoryLevel__c, 
  FSL__Mi_La__c, FSL__Ma_La__c, FSL__Mi_Lo__c, FSL__Ma_Lo__c FROM FSL__Polygon__c 
WHERE FSL__Service_Territory__c != null 
  AND FSL__Mi_La__c <= :lat 
  AND FSL__Ma_La__c >= :lat 
  AND FSL__Mi_Lo__c <= :lon 
  AND FSL__Ma_Lo__c >= :lon
  AND FSL__Service_Territory__r.RecordType.DeveloperName =:requestType LIMIT 10000

For the result I will get, I can extract the KML file, that look like

<?xml version="1.0" encoding="UTF-8"?> 
    <kml xmlns="http://www.opengis.net/kml/2.2">
        <Style id="Great Toronto CoreStyle"> 
            <name>Great Toronto</name> 
            <styleUrl>#Great TorontoStyle</styleUrl> 

Did any of you already had the same request, as based on that polygon coordinates, check if a lat/long is within it?

Thanks for your help


You must log in to answer this question.

Browse other questions tagged .