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

Rename tile.x and tile.y to tile.tx and tile.ty? #15

Closed
mbostock opened this issue Jul 1, 2016 · 4 comments
Closed

Rename tile.x and tile.y to tile.tx and tile.ty? #15

mbostock opened this issue Jul 1, 2016 · 4 comments

Comments

@mbostock
Copy link
Member

mbostock commented Jul 1, 2016

I feel like the distinction between tile[0] and tile.x is too small (or that the names are easily confused), especially since typically we substitute tile[0] as the %x variable in a URL template.

Maybe the names tile.tx and tile.ty would be better? Especially if they are premultiplied? Although I guess d3.zoomTransform uses {x, y, k}, so, I dunno.

@curran
Copy link
Contributor

curran commented Jul 2, 2016

I'm down to rename tile.x and tile.y to tile.tx and tile.ty.

From the outset I kind of felt the array representation was a bit opaque. If we're using named properties for tx and ty, it almost feels like the whole thing should just be an object with named properties only. That might be simpler for newcomers to grok, rather than having an array with properties, which may be confusing.

What are your thoughts on this idea:

var d = {
  x: 1, // previously d[0]
  y: 5, // previously d[1]
  z: 4, // previously d[2] - naming in-line with the URL templates in the Leaflet world
  tx: 256, // (x without wrapping logic applied) * 256 
  tz: 1280 // y * 256
};

@curran
Copy link
Contributor

curran commented Jul 2, 2016

I've made two PRs for two alternative representations. Which do you prefer?

@mbostock
Copy link
Member Author

mbostock commented Jul 2, 2016

The object seems like the simplest approach, yeah. I can’t think of any great wins by using the array representation. Sometimes it’s nice to use arrays for 2D points because the default toString behavior on [x, y] can be embedded into a transform, such as "translate(" + point + ")". But that’s not the case here.

@curran
Copy link
Contributor

curran commented Jul 3, 2016

Right, I thought of string generation too as one possible win for the array.

If the ordering were [z, x, y], the the URL could look like this:

"http://" + "abc"[d[1] % 3] + ".tile.openstreetmap.org/" + d.join("/") + ".png"; })

But even here, I think I would prefer to see:

"http://" + "abc"[d[1] % 3] + ".tile.openstreetmap.org/" + d.z + "/" + d.x + "/" + d.y + ".png"; })

I'll move ahead with the object version (#20) and merge it once documentation is updated.

@curran curran closed this as completed in 028b275 Jul 3, 2016
@Fil Fil mentioned this issue Apr 24, 2018
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants