Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Laspy #17

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ parts =
modwsgi
template
modwsgi-patch
liblas
laspy

develop = .

Expand Down Expand Up @@ -92,8 +92,10 @@ cmds =
>>> print line
>>> fileinput.close()

[liblas]
[laspy]
recipe = collective.recipe.cmd
on_install = true
on_update = true
cmds = ${buildout:directory}\buildout\bin\pip.exe install ${buildout:directory}\wheels\${vars:liblas}
cmds = ${buildout:directory}\buildout\bin\pip.exe install https://github.com/sitn/laspy/archive/e2a1a3307d4c252f80855c3e80ec373fdfc7265b.zip
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't work here...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you be a bit more explicit ? (stack or whatever...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh... I got it... just get rid of the .exe...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait... I am going to update the branch...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks but you also need to use / instead of \ ;)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After that I have the same right issue as the last time:

running install_lib
    creating /usr/local/lib/python2.7/dist-packages/laspytest
    error: could not create '/usr/local/lib/python2.7/dist-packages/laspytest': Permission denied

    ----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-ewBo_0-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-wP6wzv-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-ewBo_0-build
While:
  Installing laspy.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not better to use v1.3.0 from pypi?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is.... But it has been released on Friday (during the night in Europe...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really do not get why during the installation it tries to install/reach something in your Python root folder... We are using a virtual environment, so it should touch these folders....



48 changes: 28 additions & 20 deletions las_extractor/util/point_cloud_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import numpy as np
from shapely.geometry import LineString
import uuid
from liblas import file

from laspy import file
from datetime import datetime

try:
Expand Down Expand Up @@ -36,7 +37,6 @@ def generate_tile_list(line, bufferSizeMeter, outputDir, fileList, dataDir):
for row in intersectResult:
checkEmpty += 1
tileList.append(dataDir + str(row.file.strip() + '.las'))

return polygon, checkEmpty, tileList

# Read the numpy data and append them to json-serializable list
Expand Down Expand Up @@ -105,24 +105,32 @@ def pointCloudExtractorV2(coordinates, bufferSizeMeter, outputDir, dataDir, json
startIterateTile = datetime.now()
for tile in tileList:
cloud = file.File(tile, mode = 'r')
# iterate over cloud's points
for p in cloud:
# Needs enhancements...
if p.x <= max(seg['x1'] + bufferSizeMeter, seg['x2'] + bufferSizeMeter) \
and p.x >= min(seg['x1'] - bufferSizeMeter, seg['x2'] - bufferSizeMeter) \
and p.y <= max(seg['y1'] + bufferSizeMeter, seg['y2'] + bufferSizeMeter) \
and p.y >= min(seg['y1'] - bufferSizeMeter, seg['y2'] - bufferSizeMeter):
xOB = p.x - seg['x1']
yOB = p.y - seg['y1']
hypo = math.sqrt(xOB * xOB + yOB * yOB)
cosAlpha = (xOA * xOB + yOA * yOB)/(math.sqrt(xOA * xOA + yOA * yOA) * hypo)
alpha = math.acos(cosAlpha)
normalPointToLineDistance = math.sin(alpha) * hypo
# Filter for normal distance smaller or equal to buffer size
if normalPointToLineDistance <= bufferSizeMeter:
exctractedPoints.append({'x': p.x, 'y': p.y, 'z': p.z, 'classification': p.classification})
lineList = [p.x, p.y, p.z, cosAlpha, p.classification]
table.append(lineList)


for x, y, z, classification in np.nditer((cloud.x, cloud.y, cloud.z, cloud.classification)):
x = x.item()
y = y.item()
if x <= max(seg['x1'] + bufferSizeMeter, seg['x2'] + bufferSizeMeter) \
and x >= min(seg['x1'] - bufferSizeMeter, seg['x2'] - bufferSizeMeter) \
and y <= max(seg['y1'] + bufferSizeMeter, seg['y2'] + bufferSizeMeter) \
and y >= min(seg['y1'] - bufferSizeMeter, seg['y2'] - bufferSizeMeter):
xOB = x - seg['x1']
yOB = y - seg['y1']
hypo = math.sqrt(xOB * xOB + yOB * yOB)
cosAlpha = (xOA * xOB + yOA * yOB)/(math.sqrt(xOA * xOA + yOA * yOA) * hypo)
if cosAlpha > 1:
cosAlpha = 1

alpha = math.acos(cosAlpha)
normalPointToLineDistance = math.sin(alpha) * hypo
# Filter for normal distance smaller or equal to buffer size
if normalPointToLineDistance <= bufferSizeMeter:
z = z.item()
classification = classification.item()
exctractedPoints.append({'x': x, 'y': y, 'z': z, 'classification': classification})
lineList = [x, y, z, cosAlpha, classification]
table.append(lineList)

cloud.close()

stopIterateTile = datetime.now()
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
'numpy',
'pyyaml',
'pip',
'numpy'
],
packages=find_packages(exclude=['ez_setup']),
include_package_data=True,
Expand Down