diff --git a/Makefile b/Makefile index fce9f56..0402b2d 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ #Make sure to compile with: $(mysql_config --cflags) and link to: $(mysql_config --libs) a.out: gs.o - cc obj/db.o obj/gs.o obj/json.o obj/scope.o obj/comment.o obj/marker.o -o a.out -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -ldl -g + cc obj/*o -o a.out -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -ldl -g gs.o: green-serv.c json.o db.o cc -I./headers -std=gnu99 -pedantic -Wall -Wextra -Werror -g -c green-serv.c -o obj/gs.o -db.o: src/database/db.c scope.o comment.o marker.o +db.o: src/database/db.c scope.o comment.o marker.o heatmap.o cc -I./headers -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -std=gnu99 -pedantic -Wall -Wextra -Werror -g -c src/database/db.c -o obj/db.o -json.o: src/helpers/json.c comment.o scope.o marker.o +json.o: src/helpers/json.c comment.o scope.o marker.o heatmap.o cc -I./headers -std=gnu99 -pedantic -Wall -Wextra -Werror -g -c src/helpers/json.c -o obj/json.o scope.o: src/models/scope.c @@ -21,5 +21,9 @@ comment.o: src/models/comment.c marker.o: src/models/marker.c cc -I./headers -std=gnu99 -pedantic -Wall -Wextra -Werror -g -c src/models/marker.c -o obj/marker.o +#Heatmap depends on marker for implementation of createDecimal +heatmap.o: src/models/heatmap.c marker.o + cc -I./headers -std=gnu99 -pedantic -Wall -Wextra -Werror -g -c src/models/heatmap.c -o obj/heatmap.o + clean: rm obj/*.o *.out diff --git a/green-serv.c b/green-serv.c index 2b4af3c..c18cd01 100644 --- a/green-serv.c +++ b/green-serv.c @@ -5,6 +5,7 @@ #include "flags.h" #include "models/comment.h" #include "models/marker.h" +#include "models/heatmap.h" #include @@ -26,6 +27,7 @@ int main(int argc, const char* argv[]) { struct gs_comment * commentPage; struct gs_marker testMarker; struct gs_marker * markerPage; + struct gs_heatmap testHeatmap; Decimal latitude; Decimal longitude; char json[512]; @@ -114,6 +116,8 @@ int main(int argc, const char* argv[]) { fprintf(stderr, "%s\n", "Could not allocate enough memory for marker page"); } + gs_heatmap_ZeroStruct(&testHeatmap); + /*Clean Up database connection*/ mysql_close(conn); diff --git a/src/models/heatmap.c b/src/models/heatmap.c new file mode 100644 index 0000000..c697661 --- /dev/null +++ b/src/models/heatmap.c @@ -0,0 +1,45 @@ +#include +#include "models/heatmap.h" + +/* Any functions specifically working with just gs_marker: */ +void gs_mheatmap_setId(long id, struct gs_heatmap * gsh){ + gsh->id = id; +} + +void gs_heatmap_setIntensity(long intensity, struct gs_heatmap * gsh){ + gsh->intensity = intensity; +} + +void gs_heatmap_setScopeId(long scopeId, struct gs_heatmap * gsh){ + gsh->scopeId = scopeId; +} + +/* Will truncate to 19 characters */ +void gs_heatmap_setCreatedTime(char * createdTime, struct gs_heatmap * gsh){ + strncpy(gsh->createdTime, createdTime, GS_HEATMAP_CREATED_TIME_LENGTH); +} + +void gs_heatmap_setLongitude(Decimal longitude, struct gs_heatmap * gsh){ + gsh->longitude = longitude; +} + +void gs_heatmap_setLatitude(Decimal latitude, struct gs_heatmap * gsh){ + gsh->latitude = latitude; +} + + +/* Empties a marker structure of data and sets flag values */ +void gs_heatmap_ZeroStruct(struct gs_heatmap * gsh){ + bzero(gsh->createdTime, GS_HEATMAP_CREATED_TIME_LENGTH+1); + gsh->id = GS_HEATMAP_INVALID_ID; + gsh->intensity = 0; + /* 0 is actually a good 'invalid' or default for the right + * side because if someone gives just 1. or 1 to a string + * parsing function and we only set the left, the right is + * still correct! + */ + gsh->longitude.left = 0; + gsh->longitude.right = 0; + gsh->latitude.left = 0; + gsh->latitude.right = 0; +}