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

feat(parser): add a shapefile parser #1056

Merged
merged 3 commits into from
Mar 27, 2019
Merged

Conversation

zarov
Copy link
Contributor

@zarov zarov commented Mar 4, 2019

The parser can take into account four files: shp, shx, dbf and prj. It
uses https://www.npmjs.com/package/shpjs

An example and some data has been added.

This PR should not be merged before #1033

@zarov zarov added ready ✔️ feature 🍏 Adds a new feature labels Mar 4, 2019
@zarov zarov added this to the 2.9.0 milestone Mar 4, 2019
@zarov zarov force-pushed the shapefile branch 2 times, most recently from 35bab6c to 5c599bf Compare March 7, 2019 12:47
@zarov
Copy link
Contributor Author

zarov commented Mar 7, 2019

This PR can be reviewed now that #1033 has been merged.

Copy link
Contributor

@gchoqueux gchoqueux left a comment

Choose a reason for hiding this comment

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

could you move data files in itowns sample data?

examples/shapefile.html Show resolved Hide resolved

// Load all the necessary files for a shapefile, parse them and
// display them.
Promise.all([
Copy link
Contributor

Choose a reason for hiding this comment

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

could you add Fetcher.Shape(baseUrl, extentionfiles = {shp: 'shp',.... }, networkOptions)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I pushed a quick draft, let me know what you think

examples/shapefile.html Show resolved Hide resolved
src/Parser/ShapefileParser.js Show resolved Hide resolved
@zarov zarov force-pushed the shapefile branch 2 times, most recently from 951ef5d to c0df145 Compare March 12, 2019 08:48
@zarov
Copy link
Contributor Author

zarov commented Mar 12, 2019

I completed the documentation and rebased everything in 2 commits

@gchoqueux
Copy link
Contributor

I have some comments:

  • The example doesn't load, it needs to move to refresh globe. could you fix this issue?
  • I remarked the points circle are deformed in the direction of latitude because the texture have a size squared. could you open a issue? a solution to fix it, is to use PM projection.
  • The drawing of points is very slow because there is not test on extent. I have start a optimisation could add it?
    0001-optimization-draw-point.patch

@zarov
Copy link
Contributor Author

zarov commented Mar 12, 2019

examples/shapefile.html Outdated Show resolved Hide resolved
function drawFeature(ctx, feature, origin, scale, extent, style = {}) {
let gStyle = style;
// Determinate with radius point
const px = 0.01;
Copy link
Contributor

Choose a reason for hiding this comment

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

px needs to be determinate with radius, because if radius increases then the condition is wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Damn I copied/pasted it without noticing the comment, my bad ! Fixing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this seems complicated to do: it depends a lot on the current projection/view, and I don't think this will simply things. What about allowing only a maximum radius size ? I don't see a case where a point is larger than 30 or 50px, and unless someone displays this point on a globe with a zoom at 0, there will be no artefact. What do you say ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nervemind, it is done simply in fact, my bad

examples/shapefile.html Outdated Show resolved Hide resolved
@gchoqueux
Copy link
Contributor

The example doesn't load, it needs to move to refresh globe. could you fix this issue?

fixed with #1068

zarov added 2 commits March 26, 2019 09:52
The parser can take into account four files: shp, shx, dbf and prj. It
uses https://www.npmjs.com/package/shpjs

An example and some data has been added.
The new multiple method can be used to load a bunch of files having the
same base url, like the shapefile system for example.

// cross multiplication to know in the extent system the real size of
// the point
px = gStyle.radius * (extentDim.x / 256);
Copy link
Contributor

Choose a reason for hiding this comment

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

you could use ctx.canvas.width instead of 256

@gchoqueux gchoqueux merged commit e2f0c93 into iTowns:master Mar 27, 2019
@zarov zarov deleted the shapefile branch March 27, 2019 16:21
@mbredif mbredif mentioned this pull request Jun 26, 2019
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🍏 Adds a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants