PitchInteractiveInc / tilegrams

Make hexagonally tiled cartograms
http://pitchinteractiveinc.github.com/tilegrams
ISC License
214 stars 49 forks source link

Csv validate geos #66

Closed jessihamel closed 8 years ago

jessihamel commented 8 years ago

• Handles geos with 0, negative, or NaN by warning the user, then removing from data. In order to make the cartogram work, we remove it from the map geometry before calling the cartogram. • Handles extra geos (fips for places we don't have or non-existent fips) by warning the user and removing from data. This fixes a bug where bad fips codes wouldn't throw an error, but would mess up the metric calculations.

Attached image shows cartogram with no Alabama or California. screen shot 2016-10-12 at 3 12 55 pm

adamflorin commented 8 years ago

I don't think there's much functional difference, but that do like parseFloat for being explicit

On Oct 12, 2016 at 4:53 PM, <Jessica Hamel (mailto:notifications@github.com)> wrote:

@jessihamel commented on this pull request.

In source/resources/DatasetResource.js (https://github.com/PitchInteractiveInc/tilegrams/pull/66):

@@ -24,7 +26,37 @@ class DatasetResource { } parseCsv(csv) { - return csvParseRows(csv, d => [d[0], +d[1]]) + const features = mapResource.getUniqueFeatureIds() + const badMapIds = [] + const badValueIds = [] + const parsed = csvParseRows(csv, d => [d[0], +d[1]]).filter(row => { + const hasId = features.indexOf(row[0]) > -1 + if (!hasId) { + badMapIds.push(row[0]) + } + if (row[1] <= 0 || isNaN(+row[1])) {

Good point, it's already parsed as int. Do you prefer ParseFloat to + for type casting? I didn't think there was much of a difference.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub (https://github.com/PitchInteractiveInc/tilegrams/pull/66), or mute the thread (https://github.com/notifications/unsubscribe-auth/AAA87s73B6yM1vv_8k0KnGpnS0q-e8SAks5qzXMKgaJpZM4KVRyP).