Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//Attempt at mimicking an example of using GeoJSON polygon data to do basic spatial intersections in iFormBuilder.
//Original example from: https://gist.github.com/bdevoe/bc2637105b59ef0599b291f0941f215b
//input GeoJSON data for Washington State Counties, in WGS84 lat lon projection.
//Vertices have been simplified to 1 mile minimum perpendicular spacing.
var county = JSON.parse('{"displayFieldName":"","fieldAliases":{"OBJECTID":"OBJECTID","CountyNM":"CountyNM","Shape_Length":"Shape_Length","Shape_Area":"Shape_Area"},"geometryType":"esriGeometryPolygon","spatialReference":{"wkid":4326,"latestWkid":4326},"fields":[{"name":"OBJECTID","type":"esriFieldTypeOID","alias":"OBJECTID"},{"name":"CountyNM","type":"esriFieldTypeString","alias":"CountyNM","length":15},{"name":"Shape_Length","type":"esriFieldTypeDouble","alias":"Shape_Length"},{"name":"Shape_Area","type":"esriFieldTypeDouble","alias":"Shape_Area"}],"features":[{"attributes":{"OBJECTID":1,"CountyNM":"Pend Oreille","Shape_Length":3.0922356431888796,"Shape_Area":0.44815815765147882},"geometry":{"rings":[[[-117.42919769699995,49.000472750000029],[-117.03243498799998,48.999203535000049],[-117.04188810599999,48.045473996000055],[-117.43688522699995,48.047130114000026],[-117.43763879099998,48.134693239000057],[-117.50238334199997,48.134715797000069],[-117.49998954299997,48.656192937000071],[-117.62927119999995,48.655857866000076],[-117.62962584099995,48.713645668000026],[-117.62943520999994,48.742640330000029],[-117.56382541799996,48.742966298000056],[-117.56387457399995,48.836676318000059],[-117.49851098999994,48.836905148000028],[-117.49897244899995,48.923164135000036],[-117.43039150999999,48.923173650000081],[-117.42919769699995,49.000472750000029]]]}},{"attributes":{"OBJECTID":2,"CountyNM":"Stevens","Shape_Length":4.8903981149054845,"Shape_Area":0.79674494159646458},"geometry":{"rings":[[[-118.19738490999998,49.000075181000057],[-117.42919769699995,49.000472750000029],[-117.43039150999999,48.923173650000081],[-117.49897244899995,48.923164135000036],[-117.49851098999994,48.836905148000028],[-117.56387457399995,48.836676318000059],[-117.56382541799996,48.742966298000056],[-117.62943520999994,48.742640330000029],[-117.62962584099995,48.713645668000026],[-117.62927119999995,48.655857866000076],[-117.49998954299997,48.656192937000071],[-117.50238334199997,48.134715797000069],[-117.43763879099998,48.134693239000057],[-117.43688522699995,48.047130114000026],[-117.54244536099998,48.04782528100003],[-117.53446739299994,47.79306144800006],[-117.58617825999994,47.795281093000028],[-117.65327515599995,47.837270482000065],[-117.67435623799997,47.889394003000064],[-117.74366632199997,47.830030340000064],[-117.79599402399998,47.811479516000077],[-117.82096006699999,47.825783848000071],[-117.88043973199996,47.847914328000059],[-118.07787161099998,47.799158158000068],[-118.21238013299995,47.945661296000026],[-118.34132698799999,47.894387317000053],[-118.34953339999998,47.972429899000076],[-118.40120299299997,48.027518335000082],[-118.23741188299999,48.057903629000066],[-118.25503715699995,48.129128103000028],[-118.19617842799994,48.144776114000081],[-118.19456920299996,48.211868563000053],[-118.14034792899997,48.264946199000065],[-118.21383111999995,48.454744452000057],[-118.17482492999994,48.521313651000071],[-118.14100802699994,48.527897858000074],[-118.10430612499999,48.648375870000052],[-118.12243572299997,48.780316773000038],[-118.21384612399999,48.877726133000067],[-118.22016177099999,48.996747721000077],[-118.19738490999998,49.000075181000057]]]}},{"attributes":{"OBJECTID":3,"CountyNM":"Whatcom","Shape_Length":5.770784104556884,"Shape_Area":0.79619034171163616},"geometry":{"rings":[[[-123.00850019499995,48.831224054000074],[-123.32225022699998,49.002075311000056],[-120.85226281799999,49.000306875000035],[-120.88565508599999,48.975217724000061],[-120.83545137199997,48.939312697000048],[-120.79722505199999,48.959531752000032],[-120.75624180799997,48.942919176000032],[-120.77023734199997,48.881831617000046],[-120.73073161499997,48.853837395000028],[-120.73544138299997,48.786493542000073],[-120.65599382999994,48.724903085000051],[-120.75141385799998,48.657140953000066],[-120.91043722499995,48.657500026000037],[-120.91640300899996,48.640646780000054],[-122.49877397499995,48.645401348000064],[-122.59156913499999,48.625715939000031],[-122.71379007299998,48.645085963000042],[-122.70601861699998,48.670686563000061],[-122.79928870599997,48.764276352000081],[-123.00850019499995,48.831224054000074]]]}},{"attributes":{"OBJECTID":4,"CountyNM":"Ferry","Shape_Length":3.8108255653854872,"Shape_Area":0.71807656078328197},"geometry":{"rings":[[[-118.83662781599998,49.000084110000046],[-118.19738490999998,49.000075181000057],[-118.22016177099999,48.996747721000077],[-118.21384612399999,48.877726133000067],[-118.12243572299997,48.780316773000038],[-118.10430612499999,48.648375870000052],[-118.14100802699994,48.527897858000074],[-118.17482492999994,48.521313651000071],[-118.21383111999995,48.454744452000057],[-118.14034792899997,48.264946199000065],[-118.19456920299996,48.211868563000053],[-118.19617842799994,48.144776114000081],[-118.25503715699995,48.129128103000028],[-118.23741188299999,48.057903629000066],[-118.40120299299997,48.027518335000082],[-118.34953339999998,47.972429899000076],[-118.34132698799999,47.894387317000053],[-118.39031494099999,47.829842855000038],[-118.44691151999996,47.84658064000007],[-118.46315089499996,47.881363890000046],[-118.53964214799998,47.878574710000066],[-118.53498525999998,47.916066153000031],[-118.57095799499996,47.931994307000082],[-118.69263765199997,47.943029341000056],[-118.73708742799994,47.901138059000061],[-118.81619489899998,47.921981096000081],[-118.85192468999998,47.957921637000027],[-118.86984666099994,48.653711115000078],[-118.83640945299999,48.65370331500003],[-118.83662781599998,49.000084110000046]]]}},{"attributes":{"OBJECTID":5,"CountyNM":"Okanogan","Shape_Length":6.6296698112347201,"Shape_Area":1.6682281174019067},"geometry":{"rings":[[[-118.83662781599998,49.000084110000046],[-118.83640945299999,48.65370331500003],[-118.86984666099994,48.653711115000078],[-118.85192468999998,47.957921637000027],[-118.97384722799995,47.943516346000081],[-118.98224936899999,47.962271127000065],[-118.95124466299995,48.019660530000067],[-119.00601067499997,48.045571892000055],[-119.05493890599996,48.135927446000039],[-119.13097655899998,48.15119551500004],[-119.25256625199995,48.102593800000079],[-119.30730787499999,48.111789717000079],[-119.34202111499997,48.049665122000079],[-119.50433573399999,48.081421861000081],[-119.62166965699998,47.99663294100003],[-119.69206521699999,48.026705625000034],[-119.68299344699994,48.092520635000028],[-119.71975190899997,48.082069444000069],[-119.77460558599995,48.104220139000063],[-119.89536172299995,48.050050891000069],[-119.87060683899995,47.960462051000036],[-120.06656068499996,47.966404806000071],[-120.09018398899997,48.01801170400006],[-120.14640303799996,48.037350221000054],[-120.14343380399998,48.065231308000079],[-120.32671059499995,48.128827578000028],[-120.36129959599998,48.157575068000028],[-120.35555455999997,48.21842881200007],[-120.51029944899994,48.311303972000076],[-120.58682922999998,48.320328055000061],[-120.56320483699994,48.370854532000067],[-120.64994641399994,48.39814523900003],[-120.66883083299996,48.449740933000044],[-120.62841987299998,48.497358139000028],[-120.65229650299995,48.536945065000054],[-120.70208272699995,48.53159559900007],[-120.70504527799994,48.590109912000059],[-120.74414330599996,48.578849369000068],[-120.78468835599995,48.60341646300003],[-120.75141385799998,48.657140953000066],[-120.65599382999994,48.724903085000051],[-120.73544138299997,48.786493542000073],[-120.73073161499997,48.853837395000028],[-120.77023734199997,48.881831617000046],[-120.75624180799997,48.942919176000032],[-120.79722505199999,48.959531752000032],[-120.83545137199997,48.939312697000048],[-120.88565508599999,48.975217724000061],[-120.85226281799999,49.000306875000035],[-118.83662781599998,49.000084110000046]]]}},{"attributes":{"OBJECTID":6,"CountyNM":"San Juan","Shape_Length":2.0237422930089752,"Shape_Area":0.19414668232117993},"geometry":{"rings":[[[-123.00850019499995,48.831224054000074],[-122.79928870599997,48.764276352000081],[-122.70601861699998,48.670686563000061],[-122.71379007299998,48.645085963000042],[-122.76441976999996,48.600582845000076],[-122.73373936399997,48.413032201000078],[-122.76582108299999,48.370756265000068],[-122.86292682699997,48.370121950000055],[-122.95192556599994,48.348756339000033],[-123.24845359399995,48.284021454000026],[-123.11515439299995,48.422835467000027],[-123.21894445299995,48.548714075000078],[-123.26789197999994,48.693998742000076],[-123.00850121299999,48.767104344000074],[-123.00850019499995,48.831224054000074]]]}},{"attributes":{"OBJECTID":7,"CountyNM":"Skagit","Shape_Length":4.9042276031650642,"Shape_Area":0.6040373741912296},"geometry":{"rings":[[[-122.71379007299998,48.645085963000042],[-122.59156913499999,48.625715939000031],[-122.49877397499995,48.645401348000064],[-120.91640300899996,48.640646780000054],[-120.91043722499995,48.657500026000037],[-120.75141385799998,48.657140953000066],[-120.78468835599995,48.60341646300003],[-120.74414330599996,48.578849369000068],[-120.70504527799994,48.590109912000059],[-120.70208272699995,48.53159559900007],[-120.79187095099996,48.507542826000076],[-120.84466914899997,48.550558555000066],[-120.86322622499995,48.530080206000036],[-120.95051641499998,48.529587330000027],[-120.95196203699999,48.499212464000038],[-121.04972836399998,48.485405360000073],[-121.03714434099999,48.433033955000042],[-121.06644222299997,48.39354501300005],[-121.04052243699999,48.348477468000056],[-121.07160210299998,48.317807795000078],[-121.00139392699998,48.295600151000031],[-122.45861234399996,48.297709056000031],[-122.53901715999996,48.342024675000062],[-122.58606447299996,48.412641885000028],[-122.73373936399997,48.413032201000078],[-122.76441976999996,48.600582845000076],[-122.71379007299998,48.645085963000042]]]}},{"attributes":{"OBJECTID":8,"CountyNM":"Clallam","Shape_Length":4.923078529831435,"Shape_Area":0.84070904577907513},"geometry":{"rings":[[[-123.24845359399995,48.284021454000026],[-122.95192556599994,48.348756339000033],[-122.95209431299998,48.108604448000051],[-122.89747006399995,48.095808743000077],[-122.89751335299997,48.065816029000075],[-122.94919742299999,48.065128780000066],[-122.94918461999998,47.866826433000028],[-124.71717181999998,47.87900438500003],[-124.80022193099995,47.97523579500006],[-124.77809247199997,48.05980154100007],[-124.86083750899996,48.184725397000079],[-124.76673795699998,48.29319034100007],[-124.81474056299999,48.421707299000047],[-124.72726130999996,48.49344917600007],[-124.01207130699999,48.296678575000044],[-123.67908083299994,48.240002306000065],[-123.54123292499997,48.224558496000043],[-123.24845359399995,48.284021454000026]]]}},{"attributes":{"OBJECTID":9,"CountyNM":"Chelan","Shape_Length":5.3085810254361183,"Shape_Area":0.93282505422852524},"geometry":{"rings":[[[-120.70208272699995,48.53159559900007],[-120.65229650299995,48.536945065000054],[-120.62841987299998,48.497358139000028],[-120.66883083299996,48.449740933000044],[-120.64994641399994,48.39814523900003],[-120.56320483699994,48.370854532000067],[-120.58682922999998,48.320328055000061],[-120.51029944899994,48.311303972000076],[-120.35555455999997,48.21842881200007],[-120.36129959599998,48.157575068000028],[-120.32671059499995,48.128827578000028],[-120.14343380399998,48.065231308000079],[-120.14640303799996,48.037350221000054],[-120.09018398899997,48.01801170400006],[-120.06656068499996,47.966404806000071],[-119.87060683899995,47.960462051000036],[-119.86057890899997,47.940647051000042],[-119.99483864299998,47.781482367000081],[-120.08789046799996,47.763004721000073],[-120.13240938899997,47.776379936000069],[-120.20933293599995,47.748746867000079],[-120.19927551699999,47.682786424000028],[-120.23827333199995,47.586437079000063],[-120.30244447099994,47.521276346000036],[-120.29260024399997,47.400006759000064],[-120.08632283899999,47.339266492000036],[-120.09446968799995,47.262167312000031],[-120.38920685599999,47.260942796000052],[-120.52467826099996,47.333309252000049],[-120.56444280799997,47.308229606000054],[-120.57864189999998,47.337234959000057],[-120.66437744799998,47.343311701000061],[-120.80334055899999,47.423055722000072],[-120.91787492099996,47.42932653400004],[-121.11358174499998,47.597292806000041],[-121.12883650499998,47.676185349000036],[-121.06601826599996,47.71360715000003],[-121.11919030399997,47.77993987800005],[-121.07052820899997,47.828010866000056],[-121.15352478999995,47.84531634800004],[-121.18063663299995,47.897979857000053],[-121.11773658399994,47.998802799000032],[-121.15337141799995,48.040538234000053],[-121.01595475899995,48.074800415000027],[-120.94711279199998,48.113332619000062],[-120.95557905599998,48.151986631000057],[-120.90742934699995,48.163186702000075],[-121.00139392699998,48.295600151000031],[-121.07160210299998,48.317807795000078],[-121.04052243699999,48.348477468000056],[-121.06644222299997,48.39354501300005],[-121.03714434099999,48.433033955000042],[-121.04972836399998,48.485405360000073],[-120.95196203699999,48.499212464000038],[-120.95051641499998,48.529587330000027],[-120.86322622499995,48.530080206000036],[-120.84466914899997,48.550558555000066],[-120.79187095099996,48.507542826000076],[-120.70208272699995,48.53159559900007]]]}},{"attributes":{"OBJECTID":10,"CountyNM":"Island","Shape_Length":1.8039233707639246,"Shape_Area":0.1603266411096379},"geometry":{"rings":[[[-122.73373936399997,48.413032201000078],[-122.58606447299996,48.412641885000028],[-122.53901715999996,48.342024675000062],[-122.45861234399996,48.297709056000031],[-122.39313150999999,48.237944171000038],[-122.41724326299999,48.167114599000058],[-122.34565812999995,48.070760362000044],[-122.32866885699997,47.965329671000063],[-122.35593469199995,47.895349089000035],[-122.42993434099998,47.827487364000035],[-122.49881953999994,47.927001410000059],[-122.60691194199995,47.972816800000032],[-122.65632081999996,48.124488773000053],[-122.86018982999997,48.237693352000065],[-122.86292682699997,48.370121950000055],[-122.76582108299999,48.370756265000068],[-122.73373936399997,48.413032201000078]]]}},{"attributes":{"OBJECTID":11,"CountyNM":"Jefferson","Shape_Length":5.6282187324938722,"Shape_Area":0.67552207681209619},"geometry":{"rings":[[[-122.95192556599994,48.348756339000033],[-122.86292682699997,48.370121950000055],[-122.86018982999997,48.237693352000065],[-122.65632081999996,48.124488773000053],[-122.60691194199995,47.972816800000032],[-122.63776948699996,47.938433502000066],[-122.59635846999998,47.878779016000067],[-122.71835470099995,47.791822641000067],[-122.76097013299994,47.684996742000067],[-122.85760524899996,47.663422058000037],[-122.95063800899999,47.606312975000037],[-123.50461119999994,47.606538906000026],[-123.50453402299996,47.517459253000027],[-124.43098826799996,47.53293794700005],[-124.46142234499996,47.624963225000045],[-124.55464594699998,47.644429849000062],[-124.54032193999996,47.716448633000027],[-124.71717181999998,47.87900438500003],[-122.94918461999998,47.866826433000028],[-122.94919742299999,48.065128780000066],[-122.89751335299997,48.065816029000075],[-122.89747006399995,48.095808743000077],[-122.95209431299998,48.108604448000051],[-122.95192556599994,48.348756339000033]]]}},{"attributes":{"OBJECTID":12,"CountyNM":"Snohomish","Shape_Length":4.2503048615867263,"Shape_Area":0.68582804480942261},"geometry":{"rings":[[[-122.45861234399996,48.297709056000031],[-121.00139392699998,48.295600151000031],[-120.90742934699995,48.163186702000075],[-120.95557905599998,48.151986631000057],[-120.94711279199998,48.113332619000062],[-121.01595475899995,48.074800415000027],[-121.15337141799995,48.040538234000053],[-121.11773658399994,47.998802799000032],[-121.18063663299995,47.897979857000053],[-121.15352478999995,47.84531634800004],[-121.07052820899997,47.828010866000056],[-121.11919030399997,47.77993987800005],[-122.43810861099996,47.777818574000037],[-122.42993434099998,47.827487364000035],[-122.35593469199995,47.895349089000035],[-122.32866885699997,47.965329671000063],[-122.34565812999995,48.070760362000044],[-122.41724326299999,48.167114599000058],[-122.39313150999999,48.237944171000038],[-122.45861234399996,48.297709056000031]]]}},{"attributes":{"OBJECTID":13,"CountyNM":"Douglas","Shape_Length":4.0951105541700628,"Shape_Area":0.56886077870985008},"geometry":{"rings":[[[-119.68299344699994,48.092520635000028],[-119.69206521699999,48.026705625000034],[-119.62166965699998,47.99663294100003],[-119.50433573399999,48.081421861000081],[-119.34202111499997,48.049665122000079],[-119.30730787499999,48.111789717000079],[-119.25256625199995,48.102593800000079],[-119.13097655899998,48.15119551500004],[-119.05493890599996,48.135927446000039],[-119.00601067499997,48.045571892000055],[-118.95124466299995,48.019660530000067],[-118.98224936899999,47.962271127000065],[-119.10388671599998,47.961749655000062],[-119.12591694699995,47.917309285000044],[-119.21223824799995,47.887716148000038],[-119.21242281099995,47.800703442000042],[-119.29866117599994,47.728336052000031],[-119.32031630799997,47.626805110000078],[-119.40519943899994,47.612643361000039],[-119.53290235699995,47.52776439400003],[-119.53313415099996,47.441215398000054],[-119.87577029999994,47.437499756000079],[-119.91892524399998,47.364484516000061],[-120.00471781699997,47.320004045000076],[-120.00708419899996,47.220140940000078],[-120.07597934199998,47.225905989000069],[-120.09446968799995,47.262167312000031],[-120.08632283899999,47.339266492000036],[-120.29260024399997,47.400006759000064],[-120.30244447099994,47.521276346000036],[-120.23827333199995,47.586437079000063],[-120.19927551699999,47.682786424000028],[-120.20933293599995,47.748746867000079],[-120.13240938899997,47.776379936000069],[-120.08789046799996,47.763004721000073],[-119.99483864299998,47.781482367000081],[-119.86057890899997,47.940647051000042],[-119.87060683899995,47.960462051000036],[-119.89536172299995,48.050050891000069],[-119.77460558599995,48.104220139000063],[-119.71975190899997,48.082069444000069],[-119.68299344699994,48.092520635000028]]]}},{"attributes":{"OBJECTID":14,"CountyNM":"Spokane","Shape_Length":3.2536472302588213,"Shape_Area":0.55270127271465863},"geometry":{"rings":[[[-117.43688522699995,48.047130114000026],[-117.04188810599999,48.045473996000055],[-117.03988960299995,47.259280019000073],[-117.82364099299997,47.260228987000062],[-117.82096006699999,47.825783848000071],[-117.79599402399998,47.811479516000077],[-117.74366632199997,47.830030340000064],[-117.67435623799997,47.889394003000064],[-117.65327515599995,47.837270482000065],[-117.58617825999994,47.795281093000028],[-117.53446739299994,47.79306144800006],[-117.54244536099998,48.04782528100003],[-117.43688522699995,48.047130114000026]]]}},{"attributes":{"OBJECTID":15,"CountyNM":"Kitsap","Shape_Length":2.0247184359473938,"Shape_Area":0.17730713112937649},"geometry":{"rings":[[[-122.60691194199995,47.972816800000032],[-122.49881953999994,47.927001410000059],[-122.42993434099998,47.827487364000035],[-122.43810861099996,47.777818574000037],[-122.44487122999999,47.543337066000049],[-122.53701010499998,47.403359520000038],[-122.80121589599997,47.403582192000044],[-122.80017041499997,47.520147205000058],[-123.03842164699995,47.520240103000049],[-122.95063800899999,47.606312975000037],[-122.85760524899996,47.663422058000037],[-122.76097013299994,47.684996742000067],[-122.71835470099995,47.791822641000067],[-122.59635846999998,47.878779016000067],[-122.63776948699996,47.938433502000066],[-122.60691194199995,47.972816800000032]]]}},{"attributes":{"OBJECTID":16,"CountyNM":"Grant","Shape_Length":4.4274364216139626,"Shape_Area":0.86066832317542818},"geometry":{"rings":[[[-118.97384722799995,47.943516346000081],[-118.97978875099994,47.261841497000034],[-118.98266154299995,46.911348608000026],[-119.36868192499998,46.912554888000045],[-119.36946134799996,46.737593627000081],[-119.36919791699995,46.678179454000031],[-119.45311942899997,46.679308283000069],[-119.51659288899998,46.727645916000029],[-119.62772228699998,46.644012584000052],[-119.87434774999997,46.628379911000081],[-119.94562815499995,46.674402260000079],[-119.97304642599994,46.737134032000029],[-119.92575813399998,46.812039907000042],[-120.04268051199995,47.069870305000052],[-120.00159773299998,47.127786825000044],[-120.00708419899996,47.220140940000078],[-120.00471781699997,47.320004045000076],[-119.91892524399998,47.364484516000061],[-119.87577029999994,47.437499756000079],[-119.53313415099996,47.441215398000054],[-119.53290235699995,47.52776439400003],[-119.40519943899994,47.612643361000039],[-119.32031630799997,47.626805110000078],[-119.29866117599994,47.728336052000031],[-119.21242281099995,47.800703442000042],[-119.21223824799995,47.887716148000038],[-119.12591694699995,47.917309285000044],[-119.10388671599998,47.961749655000062],[-118.98224936899999,47.962271127000065],[-118.97384722799995,47.943516346000081]]]}},{"attributes":{"OBJECTID":17,"CountyNM":"Lincoln","Shape_Length":3.7785050949619543,"Shape_Area":0.72533460221320167},"geometry":{"rings":[[[-118.97384722799995,47.943516346000081],[-118.85192468999998,47.957921637000027],[-118.81619489899998,47.921981096000081],[-118.73708742799994,47.901138059000061],[-118.69263765199997,47.943029341000056],[-118.57095799499996,47.931994307000082],[-118.53498525999998,47.916066153000031],[-118.53964214799998,47.878574710000066],[-118.46315089499996,47.881363890000046],[-118.44691151999996,47.84658064000007],[-118.39031494099999,47.829842855000038],[-118.34132698799999,47.894387317000053],[-118.21238013299995,47.945661296000026],[-118.07787161099998,47.799158158000068],[-117.88043973199996,47.847914328000059],[-117.82096006699999,47.825783848000071],[-117.82364099299997,47.260228987000062],[-117.96094257399994,47.260576978000074],[-118.97978875099994,47.261841497000034],[-118.97384722799995,47.943516346000081]]]}},{"attributes":{"OBJECTID":18,"CountyNM":"King","Shape_Length":4.2152227192252285,"Shape_Area":0.71155141551432388},"geometry":{"rings":[[[-121.11919030399997,47.77993987800005],[-121.06601826599996,47.71360715000003],[-121.12883650499998,47.676185349000036],[-121.11358174499998,47.597292806000041],[-121.22891326299998,47.565607373000034],[-121.46590997299995,47.368112179000036],[-121.42750706199996,47.289081811000074],[-121.34158300899998,47.281665670000052],[-121.36512447399997,47.22443903900006],[-121.30922282999995,47.203398065000044],[-121.30342832599996,47.138897238000027],[-121.40809651699999,47.118106041000033],[-121.37997689799994,47.087254287000064],[-121.44177194299999,47.08440777800007],[-121.50976644599996,47.122508989000039],[-121.58572648399996,47.119386091000081],[-121.62954859999996,47.153434449000031],[-121.77757958899997,47.173389500000042],[-121.84029226799998,47.143226158000061],[-121.94355996099995,47.139973591000057],[-122.09478162999994,47.194980690000079],[-122.14398643599998,47.257382881000069],[-122.33487872799998,47.257598004000045],[-122.43726982499999,47.333721291000074],[-122.52043534399996,47.32277874600004],[-122.53701010499998,47.403359520000038],[-122.44487122999999,47.543337066000049],[-122.43810861099996,47.777818574000037],[-121.11919030399997,47.77993987800005]]]}},{"attributes":{"OBJECTID":19,"CountyNM":"Mason","Shape_Length":2.5118148007013992,"Shape_Area":0.32291928808954934},"geometry":{"rings":[[[-123.50453402299996,47.517459253000027],[-123.50461119999994,47.606538906000026],[-122.95063800899999,47.606312975000037],[-123.03842164699995,47.520240103000049],[-122.80017041499997,47.520147205000058],[-122.80121589599997,47.403582192000044],[-122.80618039599995,47.320685237000077],[-122.85258280399995,47.26348491400006],[-122.82059377599995,47.194225157000062],[-122.89555133699997,47.157155823000039],[-122.94237307399999,47.189039663000074],[-123.07504405799995,47.084794374000069],[-123.20190747799995,47.085063604000027],[-123.48895831999999,47.082649935000063],[-123.50453402299996,47.517459253000027]]]}},{"attributes":{"OBJECTID":20,"CountyNM":"Kittitas","Shape_Length":4.3799176104523454,"Shape_Area":0.71499360105529153},"geometry":{"rings":[[[-121.11358174499998,47.597292806000041],[-120.91787492099996,47.42932653400004],[-120.80334055899999,47.423055722000072],[-120.66437744799998,47.343311701000061],[-120.57864189999998,47.337234959000057],[-120.56444280799997,47.308229606000054],[-120.52467826099996,47.333309252000049],[-120.38920685599999,47.260942796000052],[-120.09446968799995,47.262167312000031],[-120.07597934199998,47.225905989000069],[-120.00708419899996,47.220140940000078],[-120.00159773299998,47.127786825000044],[-120.04268051199995,47.069870305000052],[-119.92575813399998,46.812039907000042],[-119.97304642599994,46.737134032000029],[-120.51000990299997,46.73795434200008],[-120.50861446599998,46.824869698000043],[-120.63399077399998,46.82578430600006],[-120.63457159999996,46.912136942000075],[-121.02663459699994,46.911422907000031],[-121.09006763499997,46.991015034000043],[-121.21885671899997,47.06564792000006],[-121.28071223899997,47.088737558000048],[-121.35925178199994,47.070746284000052],[-121.37997689799994,47.087254287000064],[-121.40809651699999,47.118106041000033],[-121.30342832599996,47.138897238000027],[-121.30922282999995,47.203398065000044],[-121.36512447399997,47.22443903900006],[-121.34158300899998,47.281665670000052],[-121.42750706199996,47.289081811000074],[-121.46590997299995,47.368112179000036],[-121.22891326299998,47.565607373000034],[-121.11358174499998,47.597292806000041]]]}},{"attributes":{"OBJECTID":21,"CountyNM":"Grays Harbor","Shape_Length":3.8691810908945778,"Shape_Area":0.69212676706173848},"geometry":{"rings":[[[-123.50453402299996,47.517459253000027],[-123.48895831999999,47.082649935000063],[-123.20190747799995,47.085063604000027],[-123.20311784799998,46.996977567000044],[-123.15838089399995,46.995875483000077],[-123.16060925999994,46.793390687000056],[-123.37096442599994,46.792134089000058],[-124.17508845899999,46.793367115000081],[-124.25271009699998,46.917511129000047],[-124.24613897099999,47.059670983000046],[-124.29785611899996,47.246532984000055],[-124.37263020399996,47.28825407800008],[-124.47879936199996,47.442689778000044],[-124.42228519199995,47.498395599000048],[-124.43098826799996,47.53293794700005],[-123.50453402299996,47.517459253000027]]]}},{"attributes":{"OBJECTID":22,"CountyNM":"Pierce","Shape_Length":3.8123766973369833,"Shape_Area":0.54980179358107184},"geometry":{"rings":[[[-122.80121589599997,47.403582192000044],[-122.53701010499998,47.403359520000038],[-122.52043534399996,47.32277874600004],[-122.43726982499999,47.333721291000074],[-122.33487872799998,47.257598004000045],[-122.14398643599998,47.257382881000069],[-122.09478162999994,47.194980690000079],[-121.94355996099995,47.139973591000057],[-121.84029226799998,47.143226158000061],[-121.77757958899997,47.173389500000042],[-121.62954859999996,47.153434449000031],[-121.58572648399996,47.119386091000081],[-121.50976644599996,47.122508989000039],[-121.44177194299999,47.08440777800007],[-121.37997689799994,47.087254287000064],[-121.45646451299996,46.923582943000042],[-121.52291722899997,46.873212400000057],[-121.45522489899997,46.783633104000046],[-121.75861220499996,46.783800042000053],[-121.84190959299997,46.728464212000063],[-121.95426290099999,46.755026460000067],[-122.04081808999996,46.742366052000079],[-122.20313384199994,46.763068645000033],[-122.28557519499998,46.774526190000074],[-122.32770035199997,46.844349641000065],[-122.49051812999994,46.867097963000049],[-122.49413439299997,46.905224426000075],[-122.56317201099995,46.935274568000068],[-122.56315080099995,46.965801489000057],[-122.62913604299996,46.971468540000046],[-122.67241593899996,47.015419861000055],[-122.69821569499999,47.116006223000056],[-122.82059377599995,47.194225157000062],[-122.85258280399995,47.26348491400006],[-122.80618039599995,47.320685237000077],[-122.80121589599997,47.403582192000044]]]}},{"attributes":{"OBJECTID":23,"CountyNM":"Whitman","Shape_Length":4.0408629585734364,"Shape_Area":0.66792672935707575},"geometry":{"rings":[[[-117.03988960299995,47.259280019000073],[-117.03977804199997,46.425895284000035],[-117.19987206799999,46.420185288000027],[-117.22813260599997,46.462253205000081],[-117.25427406699998,46.545090005000077],[-117.34897451599994,46.587681342000053],[-117.38618746299994,46.649709808000068],[-117.43275104699995,46.65946075200003],[-117.46478059799995,46.699634378000042],[-117.60049356499997,46.672495679000065],[-117.65793658099994,46.701986307000027],[-117.74088013899996,46.694591757000069],[-117.79230894199998,46.629526517000045],[-117.85209817899994,46.624661782000032],[-117.89014262999996,46.585559943000078],[-118.03241757099994,46.585573323000062],[-118.11665806499997,46.556918729000074],[-118.17131513899994,46.556764891000057],[-118.21535612899999,46.589127586000075],[-118.19801782899998,46.621868052000082],[-118.24941303899999,46.733724523000035],[-118.21025640399995,46.738842249000072],[-118.09519441199996,46.779079595000042],[-118.04445009099999,46.769172686000047],[-117.97091871099997,46.867224623000027],[-117.96094257399994,47.260576978000074],[-117.82364099299997,47.260228987000062],[-117.03988960299995,47.259280019000073]]]}},{"attributes":{"OBJECTID":24,"CountyNM":"Adams","Shape_Length":3.7791787240895154,"Shape_Area":0.58764197487720726},"geometry":{"rings":[[[-117.96094257399994,47.260576978000074],[-117.97091871099997,46.867224623000027],[-118.04445009099999,46.769172686000047],[-118.09519441199996,46.779079595000042],[-118.21025640399995,46.738842249000072],[-119.36946134799996,46.737593627000081],[-119.36868192499998,46.912554888000045],[-118.98266154299995,46.911348608000026],[-118.97978875099994,47.261841497000034],[-117.96094257399994,47.260576978000074]]]}},{"attributes":{"OBJECTID":25,"CountyNM":"Thurston","Shape_Length":2.6083391041875923,"Shape_Area":0.23827417733136055},"geometry":{"rings":[[[-123.20190747799995,47.085063604000027],[-123.07504405799995,47.084794374000069],[-122.94237307399999,47.189039663000074],[-122.89555133699997,47.157155823000039],[-122.82059377599995,47.194225157000062],[-122.69821569499999,47.116006223000056],[-122.67241593899996,47.015419861000055],[-122.62913604299996,46.971468540000046],[-122.56315080099995,46.965801489000057],[-122.56317201099995,46.935274568000068],[-122.49413439299997,46.905224426000075],[-122.49051812999994,46.867097963000049],[-122.32770035199997,46.844349641000065],[-122.28557519499998,46.774526190000074],[-122.20313384199994,46.763068645000033],[-123.16091627999998,46.76433038700003],[-123.16060925999994,46.793390687000056],[-123.15838089399995,46.995875483000077],[-123.20311784799998,46.996977567000044],[-123.20190747799995,47.085063604000027]]]}},{"attributes":{"OBJECTID":26,"CountyNM":"Yakima","Shape_Length":5.4347936578834259,"Shape_Area":1.3112811187420585},"geometry":{"rings":[[[-121.37997689799994,47.087254287000064],[-121.35925178199994,47.070746284000052],[-121.28071223899997,47.088737558000048],[-121.21885671899997,47.06564792000006],[-121.09006763499997,46.991015034000043],[-121.02663459699994,46.911422907000031],[-120.63457159999996,46.912136942000075],[-120.63399077399998,46.82578430600006],[-120.50861446599998,46.824869698000043],[-120.51000990299997,46.73795434200008],[-119.97304642599994,46.737134032000029],[-119.94562815499995,46.674402260000079],[-119.87434774999997,46.628379911000081],[-119.86584091699996,46.040866889000029],[-121.52395978299995,46.044021100000066],[-121.52002863299998,46.38872234300004],[-121.39674858799998,46.388148462000061],[-121.38638654999994,46.409981450000032],[-121.45599292599996,46.51673770900004],[-121.38672124899995,46.621213328000067],[-121.41323145099994,46.675876750000043],[-121.35319325699999,46.712274935000039],[-121.42936668999999,46.739359595000053],[-121.45522489899997,46.783633104000046],[-121.52291722899997,46.873212400000057],[-121.45646451299996,46.923582943000042],[-121.37997689799994,47.087254287000064]]]}},{"attributes":{"OBJECTID":27,"CountyNM":"Pacific","Shape_Length":2.7147421381268928,"Shape_Area":0.37433613048728442},"geometry":{"rings":[[[-123.37096442599994,46.792134089000058],[-123.35834705799999,46.384032340000033],[-123.72657215599997,46.384877703000029],[-123.72756653799996,46.26450075200006],[-123.92960651399994,46.238664119000077],[-124.02134825699994,46.292397673000039],[-124.03537536099998,46.263994939000042],[-124.15809229299998,46.249826212000073],[-124.12999696099996,46.431599309000035],[-124.17508845899999,46.793367115000081],[-123.37096442599994,46.792134089000058]]]}},{"attributes":{"OBJECTID":28,"CountyNM":"Lewis","Shape_Length":4.8771046064194934,"Shape_Area":0.74356409001590762},"geometry":{"rings":[[[-123.16060925999994,46.793390687000056],[-123.16091627999998,46.76433038700003],[-122.20313384199994,46.763068645000033],[-122.04081808999996,46.742366052000079],[-121.95426290099999,46.755026460000067],[-121.84190959299997,46.728464212000063],[-121.75861220499996,46.783800042000053],[-121.45522489899997,46.783633104000046],[-121.42936668999999,46.739359595000053],[-121.35319325699999,46.712274935000039],[-121.41323145099994,46.675876750000043],[-121.38672124899995,46.621213328000067],[-121.45599292599996,46.51673770900004],[-121.38638654999994,46.409981450000032],[-121.39674858799998,46.388148462000061],[-121.52002863299998,46.38872234300004],[-122.24098473099997,46.385371896000038],[-123.21838666499997,46.385079979000068],[-123.35834705799999,46.384032340000033],[-123.37096442599994,46.792134089000058],[-123.16060925999994,46.793390687000056]]]}},{"attributes":{"OBJECTID":29,"CountyNM":"Franklin","Shape_Length":3.2549230011889616,"Shape_Area":0.38699799324164935},"geometry":{"rings":[[[-118.21025640399995,46.738842249000072],[-118.24941303899999,46.733724523000035],[-118.19801782899998,46.621868052000082],[-118.21535612899999,46.589127586000075],[-118.22864714199994,46.59337097100007],[-118.32432262799995,46.606591119000029],[-118.39459356099997,46.580080229000032],[-118.47334972899995,46.596780971000044],[-118.61579440799994,46.504128913000045],[-118.63515918299998,46.411916554000072],[-118.70077546399995,46.36003734600007],[-118.74601393899997,46.359822879000035],[-118.76978257099995,46.293791154000075],[-118.86447634199999,46.251158814000064],[-118.97574668799996,46.237716801000033],[-119.04163493299995,46.192745819000038],[-119.26586560799996,46.273996121000039],[-119.26905315299996,46.519178546000035],[-119.45311942899997,46.679308283000069],[-119.36919791699995,46.678179454000031],[-119.36946134799996,46.737593627000081],[-118.21025640399995,46.738842249000072]]]}},{"attributes":{"OBJECTID":30,"CountyNM":"Garfield","Shape_Length":2.4588759198315637,"Shape_Area":0.21780691891407525},"geometry":{"rings":[[[-117.79230894199998,46.629526517000045],[-117.74088013899996,46.694591757000069],[-117.65793658099994,46.701986307000027],[-117.60049356499997,46.672495679000065],[-117.46478059799995,46.699634378000042],[-117.43275104699995,46.65946075200003],[-117.38618746299994,46.649709808000068],[-117.34897451599994,46.587681342000053],[-117.25427406699998,46.545090005000077],[-117.22813260599997,46.462253205000081],[-117.22880838499998,46.411314229000027],[-117.35599458899998,46.41219538100006],[-117.41934601899999,46.38314709000008],[-117.41949477999998,46.121963630000039],[-117.48000052599997,46.122002141000053],[-117.47980444099994,45.997790688000066],[-117.60343627799995,45.998957971000038],[-117.61191542099999,46.338485995000042],[-117.67495810599996,46.337658795000038],[-117.67395850699995,46.383291603000032],[-117.71646208299995,46.397615857000062],[-117.73731551099996,46.471462354000039],[-117.86335946699995,46.470675594000056],[-117.85209817899994,46.624661782000032],[-117.79230894199998,46.629526517000045]]]}},{"attributes":{"OBJECTID":31,"CountyNM":"Benton","Shape_Length":3.1647617104546857,"Shape_Area":0.53027972402595813},"geometry":{"rings":[[[-119.45311942899997,46.679308283000069],[-119.26905315299996,46.519178546000035],[-119.26586560799996,46.273996121000039],[-119.04163493299995,46.192745819000038],[-118.94231693999996,46.074427200000059],[-118.94120550499997,46.027613531000043],[-118.98727396599998,45.999861503000034],[-119.12633446099994,45.932791359000078],[-119.25708475599998,45.93987444000004],[-119.48809542699996,45.906369334000033],[-119.57161420499995,45.925485988000048],[-119.66998590399999,45.856916330000047],[-119.86832374999994,45.836206503000028],[-119.86584091699996,46.040866889000029],[-119.87434774999997,46.628379911000081],[-119.62772228699998,46.644012584000052],[-119.51659288899998,46.727645916000029],[-119.45311942899997,46.679308283000069]]]}},{"attributes":{"OBJECTID":32,"CountyNM":"Columbia","Shape_Length":2.49709264683676,"Shape_Area":0.26275593772893224},"geometry":{"rings":[[[-118.22864714199994,46.59337097100007],[-118.21535612899999,46.589127586000075],[-118.17131513899994,46.556764891000057],[-118.11665806499997,46.556918729000074],[-118.03241757099994,46.585573323000062],[-117.89014262999996,46.585559943000078],[-117.85209817899994,46.624661782000032],[-117.86335946699995,46.470675594000056],[-117.73731551099996,46.471462354000039],[-117.71646208299995,46.397615857000062],[-117.67395850699995,46.383291603000032],[-117.67495810599996,46.337658795000038],[-117.61191542099999,46.338485995000042],[-117.60343627799995,45.998957971000038],[-117.99698161199996,46.000567396000065],[-117.99149262899999,46.207709991000058],[-118.11663548899998,46.208057990000043],[-118.11612860399998,46.295463269000038],[-118.24188394299995,46.295071845000052],[-118.22864714199994,46.59337097100007]]]}},{"attributes":{"OBJECTID":33,"CountyNM":"Walla Walla","Shape_Length":3.1006062462767257,"Shape_Area":0.39294116490129494},"geometry":{"rings":[[[-118.22864714199994,46.59337097100007],[-118.24188394299995,46.295071845000052],[-118.11612860399998,46.295463269000038],[-118.11663548899998,46.208057990000043],[-117.99149262899999,46.207709991000058],[-117.99698161199996,46.000567396000065],[-118.98727396599998,45.999861503000034],[-118.94120550499997,46.027613531000043],[-118.94231693999996,46.074427200000059],[-119.04163493299995,46.192745819000038],[-118.97574668799996,46.237716801000033],[-118.86447634199999,46.251158814000064],[-118.76978257099995,46.293791154000075],[-118.74601393899997,46.359822879000035],[-118.70077546399995,46.36003734600007],[-118.63515918299998,46.411916554000072],[-118.61579440799994,46.504128913000045],[-118.47334972899995,46.596780971000044],[-118.39459356099997,46.580080229000032],[-118.32432262799995,46.606591119000029],[-118.22864714199994,46.59337097100007]]]}},{"attributes":{"OBJECTID":34,"CountyNM":"Asotin","Shape_Length":2.0061265192533564,"Shape_Area":0.19162389843844768},"geometry":{"rings":[[[-117.03977804199997,46.425895284000035],[-117.06258737399997,46.35277781800005],[-116.98577959499994,46.295492786000068],[-116.96632007099998,46.206083473000035],[-116.92233806299998,46.168543684000042],[-116.98261340299996,46.090531594000026],[-116.91524669199998,45.995313775000056],[-117.47980444099994,45.997790688000066],[-117.48000052599997,46.122002141000053],[-117.41949477999998,46.121963630000039],[-117.41934601899999,46.38314709000008],[-117.35599458899998,46.41219538100006],[-117.22880838499998,46.411314229000027],[-117.22813260599997,46.462253205000081],[-117.19987206799999,46.420185288000027],[-117.03977804199997,46.425895284000035]]]}},{"attributes":{"OBJECTID":35,"CountyNM":"Wahkiakum","Shape_Length":1.4203985347787293,"Shape_Area":0.085502540846523256},"geometry":{"rings":[[[-123.21838666499997,46.385079979000068],[-123.21323231299999,46.172990656000081],[-123.31391682299994,46.142337954000027],[-123.39055804399999,46.150115755000058],[-123.46553608799996,46.262809479000055],[-123.72756653799996,46.26450075200006],[-123.72657215599997,46.384877703000029],[-123.35834705799999,46.384032340000033],[-123.21838666499997,46.385079979000068]]]}},{"attributes":{"OBJECTID":36,"CountyNM":"Cowlitz","Shape_Length":2.8160809866679286,"Shape_Area":0.34980515871429824},"geometry":{"rings":[[[-122.24098473099997,46.385371896000038],[-122.24587406399996,46.053862806000041],[-122.29502660699995,46.049346035000042],[-122.34286056699995,45.960028629000078],[-122.49504231499998,45.987303376000057],[-122.61337893799998,45.936096037000027],[-122.69405864999999,45.941358421000075],[-122.74937301099999,45.897638821000044],[-122.71976647199995,45.86762357200007],[-122.78559000999996,45.850645962000044],[-122.81423064299997,45.960952960000043],[-122.90429098699997,46.083923946000027],[-123.12093852599997,46.186310410000033],[-123.21323231299999,46.172990656000081],[-123.21838666499997,46.385079979000068],[-122.24098473099997,46.385371896000038]]]}},{"attributes":{"OBJECTID":37,"CountyNM":"Skamania","Shape_Length":3.1784305622789475,"Shape_Area":0.50493416592646123},"geometry":{"rings":[[[-122.24098473099997,46.385371896000038],[-121.52002863299998,46.38872234300004],[-121.52395978299995,46.044021100000066],[-121.61224268399997,46.044100312000069],[-121.61274640399995,45.884703326000079],[-121.60926145699995,45.782528479000064],[-121.51439479299995,45.78212419700003],[-121.53836495899998,45.770136101000048],[-121.52369684499996,45.724940575000062],[-121.86703814999998,45.693400205000046],[-121.98301337599997,45.622900573000038],[-122.24923357499995,45.548662079000053],[-122.24587406399996,46.053862806000041],[-122.24098473099997,46.385371896000038]]]}},{"attributes":{"OBJECTID":38,"CountyNM":"Clark","Shape_Length":1.9319522943624805,"Shape_Area":0.19540030468876166},"geometry":{"rings":[[[-122.24587406399996,46.053862806000041],[-122.24923357499995,45.548662079000053],[-122.33149419399996,45.548513804000038],[-122.38010598199998,45.575791052000056],[-122.43893959399998,45.563457947000074],[-122.76400317299999,45.657274302000076],[-122.78559000999996,45.850645962000044],[-122.71976647199995,45.86762357200007],[-122.74937301099999,45.897638821000044],[-122.69405864999999,45.941358421000075],[-122.61337893799998,45.936096037000027],[-122.49504231499998,45.987303376000057],[-122.34286056699995,45.960028629000078],[-122.29502660699995,46.049346035000042],[-122.24587406399996,46.053862806000041]]]}},{"attributes":{"OBJECTID":39,"CountyNM":"Klickitat","Shape_Length":4.1402299630186112,"Shape_Area":0.57247208893969737},"geometry":{"rings":[[[-121.52395978299995,46.044021100000066],[-119.86584091699996,46.040866889000029],[-119.86832374999994,45.836206503000028],[-120.14149217699998,45.77321609300003],[-120.21078542499998,45.725923852000051],[-120.48262685799995,45.694415915000036],[-120.55929959799994,45.738323383000079],[-120.63506328799997,45.745719822000069],[-120.89583437799996,45.642931827000041],[-121.06447244999998,45.652499846000069],[-121.16786284999995,45.606098262000046],[-121.21578019199995,45.671237560000066],[-121.52369684499996,45.724940575000062],[-121.53836495899998,45.770136101000048],[-121.51439479299995,45.78212419700003],[-121.60926145699995,45.782528479000064],[-121.61274640399995,45.884703326000079],[-121.61224268399997,46.044100312000069],[-121.52395978299995,46.044021100000066]]]}}]}')
//function to determine if x,y point is within polygon. The point argument is input as an x,y array and the polygon arg is an array of x,y arrays.
PointInPolygon = function (point, vs) {
// ray-casting algorithm based on
// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
// sourced from https://github.com/substack/point-in-polygon
var x = point[0], y = point[1];
var inside = false;
for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) {
var xi = vs[i][0], yi = vs[i][1];
var xj = vs[j][0], yj = vs[j][1];
var intersect = ((yi > y) != (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
if (intersect) inside = !inside;
}
return inside;
};
//function to take point and iterate through GeoJSON of zones, returning what zones the point is in
//argument point is an array representing the [lon, lat] of the point
//works with multi-part features but does not work with donut features
WhatCounty = function (point) {
var incounty = [];
var x;
//iterate through features in json
for (x in county=.features) {
var county_nm = county.features[x].attributes.CountyNM;
var y;
//iterate through parts of multi-part features
for (y in county.features[x].geometry.rings) {
var polygon = county.features[x].geometry.rings[y];
var inside = PointInPolygon(point, polygon);
if (inside === true && incounty.includes(county_nm) === false) {
incounty.push(county_nm);
}
}
}
return incounty.sort().toString();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment