안녕 모두.
여기에 설명 할이 매우 복잡한 질문이 있습니다. 기본적으로 이것은 데이터 테이블입니다.

아래 그림과 같이 특정 좌표 주위에 8 개의 사각형이 있다는 것을 상상하여 JSL 스크립트를 사용하여 "Total Coordinates Around You"라는 열을 만들어야합니다. 여기에는 작은 파란색 원 이 특정 좌표를 나타냅니다. 따라서 최대 "총 주변 좌표"는 8입니다. 예를 들어 위의 그림에서 보듯이 9998887의 좌표 (-2,1)는 "-2, -2, -1,1"인 3의 "Total Coordinates Around You"를 갖습니다. (-1,0). 음표의 경우, 가로축은 x 좌표의 시프트를 나타내고, 마찬가지로 세로 축은 x 좌표의 시프트를 나타냅니다. 위의 데이터 표에서 20 개의 "주변 좌표계"를 쉽게 만들 수 있지만 실제 작업에는 약 23,000 개 이상의 행을 처리해야합니다. 또한, 한 가지 더 말하지만, 위의 데이터 표에 표시된 9465371과 9998887과 같은 숫자를 정렬해야합니다 (모두 동일한 좌표를 가짐). "Total Coordinates Around You"에서 작업하기 전에.

dt = current data table();
dt << New column ("Total Coordinates Around You",
numeric,
continuous,
formula (
For ( i = 1, i<= N Row(), i++,
(:Total Coordinates Around You = 0; munipulated_x = :X-Coordinate - 1; munipulated_y = Y-Coordinate - 1; j = 1; k = 1; formula (
For ( j = 1, j <= 3, j++,
(formula(
For ( k = 1, k <= 3, k++,
(formula( If (munipulated_x == :X-Coordinate & munipulated_y == :Y-Coordinate, :Total Coordinates Around You))
; munipulated_y ++)
)
) ; munipulated_x ++)
)
) ; :Total Coordinates Around You --)
)
)
);위의 스크립트는 제가 작성한 스크립트입니다. 왜 이것이 루프를 사용하여 작동하지 않을지 잘 모르겠습니다. 누군가가이 문제를 다루는 방법과 단계에 대한 나에게 계몽 수 있습니까? 이 질문에 대한 두 번째 부분이 있는데, 첫 번째 부분을 마친 후에 시도해 볼 것입니다. 특히 질문과 설명의 명료성에 의심의 여지가있을 때 설명 할 수있게 해주십시오. 그리고 다시 한 번 설명해주십시오. 고맙습니다.
나는 각 행에 대해 실행되기 때문에 공식에서하지 않을 것입니다. 그래서 공식의 내부를 반복하면 꽤 느려질 것입니다.
이것은 아마도 최선의 방법은 아니지만 작동하는 것 같습니다. 내가 올바르게 이해하고 얼마나 많은 타일이 처음 타일에 닿았는지 찾으려고한다고 가정합니다.
이것이 당신이하려는 일인 경우 알려주십시오.
Names default to here(1);
dt = New Table( "Example",
Add Rows( 20 ),
New Column( "Number",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[9465371, 9465371, 9465371, 9465371, 9465371, 9465371, 9465371, 9465371,
9465371, 9465371, 9998887, 9998887, 9998887, 9998887, 9998887, 9998887,
9998887, 9998887, 9998887, 9998887]
)
),
New Column( "X-Coordinate",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[2, 2, 1, 1, 0, 0, -1, -1, -2, -2, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2]
)
),
New Column( "Y-Coordinate",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [2, 1, 0, -1, 3, 2, 1, 0, 2, 1, 2, 1, 0, -1, 3, 2, 1, 0, 2, 1] )
),
New Column("Adjacent", Numeric, "Continuous")
);
summarize(dt, byn = By(:Number));
for(i=1, i<=nitems(byn), i++,
sel = byn[i];
rows = dt << Get Rows Where(:Number == num(sel));
mat = dt[rows, {"X-Coordinate", "Y-Coordinate"}];
for(k = 1, k<=nrows(rows), k++,
row = rows[k];
// do a check that you're within the limit
adj = sqrt( (mat[k, 1] - mat[0, 1])^2 + (mat[k, 2] - mat[0, 2])^2) <= sqrt(2);
Column(dt, "Adjacent")[row] = nrows(Loc(adj)) - 1;
)
);요구 사항을 이해할 수 있는지 확실하지 않지만 주어진 점에 인접 점을 찾으려면 'KDTable ()'을 사용하여 onsider를 사용할 수 있습니다. 예 :
Names Default To Here( 1 );
n = 100; // Size of square
// Make a table of x and y locations
dtx = AsTable((1::n)`, << Invisible);
dty = AsTable((1::n)`, << Invisible);
dt = dty << Join( With( dtx ), Cartesian Join );
Close(dtx, NoSave);
Close(dty, NoSave);
Column(dt, 1) << setName("x");
Column(dt, 2) << setName("y");
dt << deleteProperty("Source");
dt << setName("xy Locations");
// Put thes locations into a matrix
mat = dt << getAsMatrix;
tbl = KDTable( mat );
// Pick a point in the interior, so we don't need to decide on any boundary conditions
myX = RandomInteger(2, n-1);
myY = RandomInteger(2, n-1);
myRow = Loc(mat[0, 1] == myX & mat[0, 2] == myY);
myRow = myRow[1];
// Find the 8 nearest neighbours to the chosen point
{rows, dist} = tbl << K nearest rows( 8, myRow );
Show( myRow, rows );
// Check it worked
myXvals = Column(dt, "x")[myRow];
myYvals = Column(dt, "y")[myRow];
dt << NewColumn("Distance", Numeric, Continuous, Formula(sqrt((:x - myXvals)^2 +(:y - myYvals)^2)));
dt << selectRows(VConcat(myRow, rows`));
gb = dt << Graph Builder(
Size( 529, 453 ),
Show Control Panel( 0 ),
Variables( X( :x ), Y( :y ), Color( :Distance ) ),
Elements( Points( X, Y, Legend( 5 ) ) )
);