Skip to content
This repository has been archived by the owner on Sep 23, 2022. It is now read-only.

Make edge list an edge map #32

Closed
hellkite500 opened this issue Nov 24, 2020 · 6 comments
Closed

Make edge list an edge map #32

hellkite500 opened this issue Nov 24, 2020 · 6 comments

Comments

@hellkite500
Copy link

The *_edge_list.json files generated are lists of edge mappings:

[
  {
    "id": "cat-27",
    "toid": "nex-26"
  },
  {
    "id": "cat-52",
    "toid": "nex-34"
  },
  {
    "id": "cat-67",
    "toid": "nex-68"
  }
]

This is really just a map, and would likely be better suited for look ups if structured as one:

{
    "cat-27": "nex-26",
    "cat-52": "nex-34",
    "cat-67": "nex-68"
}
@dblodgett-usgs
Copy link
Owner

What's the argument for the change? It's more compact, but losing the "id" "toid" makes the data a little too cryptic for my taste.

@hellkite500
Copy link
Author

The argument is very similar to the crosswalk change already implemented. Keeping a list of objects requires iteration of the list to find a s single element, whereas bringing the local id out and mapping from that allows quick lookup of elements by id.

It could look more like the crosswalk and still not require iterating:

{
    "cat-27": {
        "toid": "nex-26"
    },
    "cat-52": {
        "toid": "nex-34"
    },
    "cat-67": {
        "toid": "nex-68"
    }
}

@dblodgett-usgs
Copy link
Owner

OK -- we can do this. I wonder if there's a better form for topology though? Is this a pressing need or can I back burner?

@hellkite500
Copy link
Author

Obviously pressing, can't you tell?

@dblodgett-usgs
Copy link
Owner

catchment_edge_map.json
{
  "cat-8895442": "nex-250031932",
  "cat-8895520": "nex-250031930",
  "cat-8895396": "nex-250031903",
  "cat-8895402": "nex-250031930",
  "nex-250031932": "cat-8895402",
  "nex-250031930": "cat-8895396",
  "nex-250031903": "cat-0"
}

or:

catchment_edge_map.json
{
  "cat-8895442": {
    "toid": "nex-250031932"
  },
  "cat-8895520": {
    "toid": "nex-250031930"
  },
  "cat-8895396": {
    "toid": "nex-250031903"
  },
  "cat-8895402": {
    "toid": "nex-250031930"
  },
  "nex-250031932": {
    "toid": "cat-8895402"
  },
  "nex-250031930": {
    "toid": "cat-8895396"
  },
  "nex-250031903": {
    "toid": "cat-0"
  }
}

@hellkite500
Copy link
Author

hellkite500 commented Dec 15, 2020

I would go with the first form:

catchment_edge_map.json
{
  "cat-8895442": "nex-250031932",
  "cat-8895520": "nex-250031930",
  "cat-8895396": "nex-250031903",
  "cat-8895402": "nex-250031930",
  "nex-250031932": "cat-8895402",
  "nex-250031930": "cat-8895396",
  "nex-250031903": "cat-0"
}

To enforce a 1-1 mapping.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants