Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Landowner Border Detector

BadPenguin Posthorn
Registered User
Join date: 17 Dec 2006
Posts: 39
02-17-2007 11:14
Detects and displays border line information of contigious land owned by the same landowner the scripted object is rezzed in.

CODE

//
// LandownerBorderDetector
// Version 20070217-1
// Copyright (c) 2007 by Second Life resident Badpenguin Posthorn
//
// Plop this script in an object and touch the object to display border
// lines and boundary coordinates of contiguous land owned by the same
// landowner. Works by detecting changes in land ownership and is
// accurate up to 0.5 meters. Note that it will only detect boundaries
// on the direct X and Y coordinates from where the scripted object
// resides, so only expect useful results when the boundaries of the
// measured parcel(s) are straight lines. Works on group deeded land
// also.
//
//
// LICENSE:
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the:
// Free Software Foundation, Inc.
// 59 Temple Place Suite 330
// Boston, MA 02111-1307, USA.
// (Also available at http://www.gnu.org/copyleft/gpl.html)
//
//
// Global variables, feel free to customize
//
float gJumpAmount = 0.5;

// *************************************************
// Find a land border by searching out from a
// specific coordinate for a change in land ownership.
// *************************************************
vector findBorder(string axis, vector start_vec, float jump_amount) {
float x = 0;
float y = 0;
float z = 0;
float num = 0;
vector newVec = ZERO_VECTOR;
vector lastVec = ZERO_VECTOR;
key owner1 = NULL_KEY;
key owner2 = NULL_KEY;
//
// Validate axis
//
if ((axis != "x") && (axis != "y")) {
// llSay(0,"Invalid axis passed to findBorder()");
return ZERO_VECTOR;
}
//
// Validate jump_amount
//
if ((integer)jump_amount >= 255) {
// llSay(0,"Invalid jump amount");
return ZERO_VECTOR;
}
//
// Validate start_vec
//
x = getVectorAxis(0,start_vec);
y = getVectorAxis(1,start_vec);
z = getVectorAxis(2,start_vec);
if (x <= 0 || y <= 0 || z <= 0) {
// llSay(0,"Invalid vector passed to findBorder()");
return ZERO_VECTOR;
}
if (x >= 255 || y >= 255 || z >= 255) {
// llSay(0,"Invalid vector passed to findBorder()");
return ZERO_VECTOR;
}
//
// Are we too close to a sim border?
//
if (axis == "x") {
if ((x + jump_amount >= 255) ||(x + jump_amount <= 0)) {
return ZERO_VECTOR;
}
} else {
if ((y + jump_amount >= 255) ||(y + jump_amount <= 0)) {
return ZERO_VECTOR;
}
}
//
// Get owner of land at start vector
//
owner1 = llGetLandOwnerAt(start_vec);
if (owner1 == NULL_KEY) {
// llSay(0,"Could not determine land owner at the location");
return ZERO_VECTOR;
}
//
// Assign initial values
//
lastVec = start_vec;
if (axis == "x") {
num = x;
} else {
num = y;
}
//
// Loop through until we find a different landowner
//
while ((num >= 0) && (num <= 255)) {
if (axis == "x") {
newVec = <num, y, z> + <jump_amount, 0, 0>;
} else {
newVec = <x, num, z> + <0, jump_amount, 0>;
}
owner2 = llGetLandOwnerAt(newVec);
if ((owner2 == NULL_KEY) || (owner1 != owner2)) {
return lastVec;
}
num += jump_amount;
if ((num <= 0) || (num >= 255)) {
return lastVec;
}
lastVec = newVec;
}
return ZERO_VECTOR;
}

// *************************************************
// Return a particular axis from a vector
// *************************************************
float getVectorAxis(integer axis, vector vec) {
if ((axis < 0) || (axis > 2)) {
return -1;
}
list junk = llParseString2List((string)vec,[",","<",">"], []);
if (llGetListLength(junk) != 3) {
return -1;
}
return llList2Float(junk,axis);
}


//
// default state starts here
//
default {
state_entry() {
llSay(0,"Touch the object to determine borders");
}

touch_start(integer num_detected) {
// Uncomment to disallow anyone but the owner to use it
//if (llDetectedKey(0) != llGetOwner()) {
// return;
// }
vector BOUND_EAST = ZERO_VECTOR;
vector BOUND_NORTH = ZERO_VECTOR;
vector BOUND_SOUTH = ZERO_VECTOR;
vector BOUND_WEST = ZERO_VECTOR;
string msg;
vector HOME_POS = llGetPos();
//
// Determine the northern boundary
//
BOUND_NORTH = findBorder("y",HOME_POS,gJumpAmount);
if (BOUND_NORTH == ZERO_VECTOR) {
llSay(0,"Failed to locate northern boundary");
llResetScript();
}
//
// Determine the southern boundary
//
BOUND_SOUTH = findBorder("y",HOME_POS,-gJumpAmount);
if (BOUND_SOUTH == ZERO_VECTOR) {
llSay(0,"Failed to locate southern boundary");
llResetScript();
}
//
// Determine the eastern boundary
//
BOUND_EAST = findBorder("x",HOME_POS,gJumpAmount);
if (BOUND_EAST == ZERO_VECTOR) {
llSay(0,"Failed to locate eastern boundary");
llResetScript();
}
//
// Determine the western boundary
//
BOUND_WEST = findBorder("x",HOME_POS,-gJumpAmount);
if (BOUND_WEST == ZERO_VECTOR) {
llSay(0,"Failed to locate western boundary");
llResetScript();
}
//
// Format some results for displaying
//
float borderNorth = getVectorAxis(1,BOUND_NORTH);
float borderSouth = getVectorAxis(1,BOUND_SOUTH);
float borderEast = getVectorAxis(0,BOUND_EAST);
float borderWest = getVectorAxis(0,BOUND_WEST);
float zCoord = getVectorAxis(2,HOME_POS);
vector vectorNW = <borderNorth, borderWest, zCoord>;
vector vectorNE = <borderNorth, borderEast, zCoord>;
vector vectorSE = <borderSouth, borderEast, zCoord>;
vector vectorSW = <borderSouth, borderWest, zCoord>;
//
// Display the results
//
llSay(0,"");
llSay(0,"Northern Boundary Detected: " + (string)BOUND_NORTH);
llSay(0,"Southern Boundary Detected: " + (string)BOUND_SOUTH);
llSay(0,"Eastern Boudary Detected: " + (string)BOUND_EAST);
llSay(0,"Western Boundary Detected: " + (string)BOUND_WEST);
llSay(0,"");
llSay(0,"Northern Border Line: " + (string)borderNorth);
llSay(0,"Southern Border Line: " + (string)borderSouth);
llSay(0,"Eastern Border Line: " + (string)borderEast);
llSay(0,"Western Border Line: " + (string)borderWest);
llSay(0,"");
llSay(0,"Northwest Coords: " + (string)vectorNW);
llSay(0,"Northeast Coords: " + (string)vectorNE);
llSay(0,"Southeast Coords: " + (string)vectorSE);
llSay(0,"Southwest Coords: " + (string)vectorSW);
}

on_rez(integer num) {
llResetScript();
}

}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
02-17-2007 14:31
/15/3c/166750/1.html
_____________________
i've got nothing. ;)
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
02-17-2007 15:52
Hi BadPenguin

Nice script. However, land can only be subdivided into 4 m length sides or multiples thereof, so your gJumpAmount should be 4.0

I use the prim count to detect adjacent parcels belonging to one owner, not infallible but works mostly. I believe you could also set the parcel's url and test for that for different parcels if the script belongs to the land owner.

Ed
BadPenguin Posthorn
Registered User
Join date: 17 Dec 2006
Posts: 39
02-17-2007 17:46
From: ed44 Gupte
Hi BadPenguin

Nice script. However, land can only be subdivided into 4 m length sides or multiples thereof, so your gJumpAmount should be 4.0

Yes, but where you place this scripted object is probably not going to be residing on a coordinate that falls within that 4m division. The 0.5m jump allows the object to be placed within 0.6m of whatever boundaries you are attempting to measure. The higher the jump amount the less accurate the result... Of course, it isn't 100% accurate no matter which way I do it ;)

From: ed44 Gupte
I use the prim count to detect adjacent parcels belonging to one owner, not infallible but works mostly. I believe you could also set the parcel's url and test for that for different parcels if the script belongs to the land owner.


This script measures boundaries of land ownership, not parcel boundaries. One land owner, or group, can own several adjacent parcels. What I was looking for originally was a way to obtain coordinates in an automated fashion so that I can have an object fly around randomly within my own land boundaries...
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
02-17-2007 20:31
Sorry about the parcel/property mixup. I am doing some terraforming with a non physical vehicle and I am trying different ways to restrict it. On islands terraforming can get away from you and make a big mess.

Property lines are always on multiples of 4 meters, so you should be able to measure them very accurately.
BadPenguin Posthorn
Registered User
Join date: 17 Dec 2006
Posts: 39
02-18-2007 11:52
From: ed44 Gupte
Property lines are always on multiples of 4 meters, so you should be able to measure them very accurately.

Hmm, next time I can actually connect to the grid I am going to have to figure out how to nail it down to measuring to that last 4m boundary. I was confusing what you were saying with grid coordinates of land boundaries always being multiples of 4m... Thanks for the hint.