Created
May 7, 2010 12:59
-
-
Save nathankerr/393386 to your computer and use it in GitHub Desktop.
Revisions
-
nathankerr created this gist
May 7, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ /* remove all residential parcels */ parcel = parcels->data; head = &(parcels->data); while(parcel != NULL) { if(strncmp(parcel->data[2], "R", 1) == 0) { head = &(parcel->next); parcel = parcel->next; } else { *head = parcel->next; clusterGIS_Free_record(parcel); parcel = *head; } } /* Find the min distance */ employer = employers->data; min = malloc(sizeof(double)*2); global_min = malloc(sizeof(double)*2); output = clusterGIS_Create_dataset(); while(employer != NULL) { /* find the local min */ parcel = parcels->data; GEOSDistance(employer->geometry, parcel->geometry, &min_distance); min_distance_parcel = parcel; while(parcel != NULL) { if(strncmp(employer->data[2], parcel->data[2], 1) == 0) { GEOSDistance(employer->geometry, parcel->geometry, &distance); if(distance < min_distance) { min_distance = distance; min_distance_parcel = parcel; } } parcel = parcel->next; } /* find the global min */ min[0] = atoi(min_distance_parcel->data[0]); min[1] = min_distance; MPI_Allreduce(min, global_min, 2, MPI_DOUBLE, min_distance_op, parcels_comm); /* Add the min to the output dataset using front insertion*/ sprintf(output_csv, "\"%s\",\"%d\"\n", employer->data[0], (int) global_min[0]); start = 0; output_record = clusterGIS_Create_record_from_csv(output_csv, &start); output_record->next = output->data; output->data = output_record; employer = employer->next; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ if(rank == 0) { int start = 0; record = clusterGIS_Create_record_from_csv("97123897,POINT(0 0),C\n", &start); record->next = dataset->data; dataset->data = record; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ box = GEOSWKTReader_read(reader, "POLYGON((-112.0859375 33.4349975585938,-112.0859375 33.4675445556641,-112.059799194336 33.4675445556641,-112.059799194336 33.4349975585938,-112.0859375 33.4349975585938))"); record = dataset->data; head = &(dataset->data); /* keep records that match the criteria, otherwise delete them */ while(record != NULL) { char intersects; intersects = GEOSIntersects(record->geometry, box); if(intersects == 1) { /* record overlaps with box */ head = &(record->next); record = record->next; } else { /* no overlap */ *head = record->next; clusterGIS_Free_record(record); record = *head; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ record = dataset->data; head = &(dataset->data); /* keep records that match the criteria, otherwise delete them */ while(record != NULL) { if(atoi(record->data[0]) == 1008130) { head = &(record->next); record = record->next; } else { *head = record->next; clusterGIS_Free_record(record); record = *head; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ record = dataset->data; /* keep records that match the criteria, otherwise delete them */ while(record != NULL) { if(atoi(record->data[0]) == 1008130) { record->data[2] = "C"; } record = record->next; }