function TestInArea() -- Define area as N49, 37', 40"/W2,32',20" x N49,24',30/W2,18',40" --Enter the RP Names below local mrp1 = 'RP-6380' local mrp2 = 'RP-6381' local mrp3 = 'RP-6382' local mrp4 = 'RP-6383' local nameRp1 = 'PortsInAreaA' -- 'RP-999100' local nameRp2 = 'PortsInAreaB' -- 'RP-999101' local nameRp3 = 'PortsInAreaC' -- 'RP-999102' local nameRp4 = 'PortsInAreaD' -- 'RP-999103' mimicmanualnames = false if mimicmanualnames then nameRp1 = 'RP-9100' nameRp2 = 'RP-9101' nameRp3 = 'RP-9102' nameRp4 = 'RP-9103' end --PortsInAreaA --setup local testside = VP_GetSides ()[1].name print("testside name is :" .. tostring(testside)); local port = { name = 'Saint Sampson', shore = { latitude = 49.483063014392, longitude = -2.4516231803573 }, harbor = { latitude = 49.517535014333, longitude = -2.4226977379214 }, country = 'Guernsey' } local retval,testship = pcall(ScenEdit_AddUnit,{type ='Ship', unitname =port.name .. " Buoy", dbid=347, side=testside, Latitude=port.harbor.latitude,Longitude=port.harbor.longitude}) ; if (retval == false) or testship == nil then print("failed to generate ship, aborting."); return; end local size = 1 local rp1=ScenEdit_AddReferencePoint( {side=testside, name=nameRp1, lat=testship.latitude + (size/10), lon=testship.longitude - (size/10),highlighted=true}) local rp2=ScenEdit_AddReferencePoint( {side=testside, name=nameRp2, lat=testship.latitude + (size/10), lon=testship.longitude + (size/10),highlighted=true}) local rp3=ScenEdit_AddReferencePoint( {side=testside, name=nameRp3, lat=testship.latitude - (size/10), lon=testship.longitude + (size/10),highlighted=true}) local rp4=ScenEdit_AddReferencePoint( {side=testside, name=nameRp4, lat=testship.latitude - (size/10), lon=testship.longitude - (size/10),highlighted=true}) -- test if testship ~= nil then t = testship:inArea({'RP-6380','RP-6381','RP-6382','RP-6383'}) print("Manual RPs tested testship:inArea({\"RP-6380\",\"RP-6381\",\"RP-6382\",\"RP-6383\"}) match:") print(t) t = testship:inArea({mrp1,mrp2,mrp3,mrp4}) print("Manual RPs tested testship:inArea({'" .. mrp1 .. "','" .. mrp2 .. "','" .. mrp3 .. "','" .. mrp4 .. "'}) match:") print(t) t = testship:inArea({nameRp1,nameRp2,nameRp3,nameRp4}) print("Lua based RPs ceated using ScenEdit_AddReferencePoint tested testship:inArea({'" .. nameRp1 .. "','" .. nameRp2 .. "','" .. nameRp3 .. "','" .. nameRp4 .. "'}) match:") print(t) t = testship:inArea({rp1.name,rp2.name,rp3.name,rp4.name}) print("Lua based RPs ceated using ScenEdit_AddReferencePoint tested testship:inArea({" .. rp1.name .."," .. rp2.name .."," .. rp3.name ..",".. rp4.name .."}) match:") print(t) t = testship:inArea({'PortsInAreaA','PortsInAreaB','PortsInAreaC','PortsInAreaD'}) print("Lua based RPs ceated using ScenEdit_AddReferencePoint tested testship:inArea({hardcoded names PostsInAreaA-B}) match:") print(t) t = testship:inArea({rp1.guid,rp2.guid,rp3.guid,rp4.guid}) print("Lua based RPs ceated using ScenEdit_AddReferencePoint tested testship:inArea({rp1.guid,rp2.guid,rp3.guid,rp4.guid}) match:") print(t) end -- cleanup strnum = ScenEdit_InputBox ('pause before cleanup') if testship ~= nil and testship:delete() then end ScenEdit_DeleteReferencePoint ({side=testside, guid=rp1.guid}) ScenEdit_DeleteReferencePoint ({side=testside, guid=rp2.guid}) ScenEdit_DeleteReferencePoint ({side=testside, guid=rp3.guid}) ScenEdit_DeleteReferencePoint ({side=testside, guid=rp4.guid}) end TestInArea()