cumulatively calculate the distance along a line

I am using Postgis to:

  • calculate the cumulative distance in metres along the line
  • store the cumulative distance in "m"

I have a table with points on this line and each row holds lat and lon coordinates. The "m" value is 0 for all rows.

The following code nicely gets me the distance between the first point and the next.

SELECT a.geom FLOOR( ST_Distance(ST_Transform(a.geom, 3857), ST_Transform(b.geom, 3857)) * cosd(42.3521)) AS dist FROM line a LEFT JOIN line b ON = + 1 

however, it does not add up to a total nor does it update the "m" value yet.

I tried a set of permutations of the following, but none of them store a cumulative sum of the previous row’s value for "m" plus the calculation of the distance between this point and the previous.

WITH next AS (     SELECT     ST_Distance(ST_Transform(a.geom, 3857), ST_Transform(b.geom, 3857)) * cosd(42.3521)     AS dist, AS rowid,     FROM line a     JOIN line b     ON = + 1 ) UPDATE line a SET m = FLOOR(next.m + next.dist) FROM next WHERE = next.rowid RETURNING a.m, next.dist; 


update line a     set m = FLOOR(a.m + prev.dist)      from (select             l.*,             ST_Distance(ST_Transform(                 lag(geom) over (order by asc)             , 3857), ST_Transform(geom, 3857)) * cosd(42.3521) as dist             from line l           ) AS prev     where = - 1     returning prev.m, prev.dist, a.m 

Any ideas?

Disallow line breaks in long Row

I’m displaying a long row of images with a horizontal scrollbar that should make the images ‘go off the screen’ to the left or right, instead of wrapping to display all the images on multiple lines.

images = Table[    ExampleData[RandomChoice[ExampleData["TestImage"]]], {i, 30}]; Pane[Row[images], Scrollbars -> {True, False}] 

I don’t know how to force the layout engine to not wrap the elements of the array. Appending SpanFromLeft or other spanning restrictions to each element doesn’t work. LineBreakWithin -> False would seem to be the easiest solution, but it doesn’t work, and isn’t ‘fully integrated’ into the language and ‘subject to change’. Perhaps some setting of LinebreakAdjustments would do it, but it probably fails for the same reason LineBreakWithin does.

How can I tell Row to have an infinite page width and not wrap while formatting so that Pane can just scroll one longer-than-screen width row of images?

Creating a SoP Energy Wall in a straight line

Using the Spheres of Power rules, the destruction sphere has a talent called Energy Wall

You may spend a spell point to shape your destructive blast into either a wall up to 20 ft. per caster level or a hemisphere with a radius up to 5 ft. per 2 caster levels (minimum: 5 ft). This wall extends up to 20 ft. high and lasts for 1 round per caster level. The wall does not block line of effect, line of sight, projectiles, or thrown objects.

Creatures passing through your wall suffer your destructive blast’s damage and effects as normal. Creatures standing in the wall’s space when it is created are allowed a Reflex save to avoid damage.

I have the following questions:

  • Does the wall have to be created in a straight line (if not using the hemisphere version)?
  • If the wall is a straight line, say down a 5 foot wide corridor, would someone traveling down the corridor take damage each square of movement?

Is there a minimum requirement for a character to have line of effect with Shadow Jaunt/Stride/Blink?

I’m pretty sure this has been asked already but I can’t find the question in question, so I hope I don’t break any rules by asking again.

The Shadow X maneuvers from Shadow Hand have a line of effect and line of sight requirement to work. Let’s say I want to teleport through a hole in a wall. According to both line rules, as long as I can see though the hole and there is nothing obstructing the path though the hole, I should be able to teleport though it.

Is there a minimum size the hole has to be for my character to be able to traverse the hole?

A cache has 64K lines where each line can store 8 blocks of the memory at a time

A cache has 64K lines where each line can store 8 blocks of the memory at a time. If the size of the memory is 2GB and block size is 4 Bytes, then which cache line is supposedly be holding the memory block with number "256" if cache supports Direct Mapping. Also compute total number of blocks this memory has and total number of blocks the cache in question can store at a time.

approximate line segments from array of unsorted points

Sample Scenario

The polygon above is actually a collection of a lot of black points closely packed together. I want to approximate these black points as straight line segments. The black points are not sorted in any order.

What I’m doing right now is sort these points by selecting any random black point and recursively finding the next closest point until no more points are left, the problem with this method is it might produce inaccurate results, if there is a small gap of points somewhere on the shape or dense lump of points somewhere on the shape. After sorting the points by this algorithm I run Douglas–Peucker algorithm to obtain the line segments. Am I doing it right? How can I approach this problem better?