Enabling spatial support into model mommy #94
Conversation
Do you intend to add tests? ;-) |
Hi @vandersonmota! Yes I do :D. I'm actually creating them right now inside the app I'll be using the modified model_mommy. I saw that the travis build failed. Let me correct everything and I'll resubmit it. |
Ok. thank you! |
@vandersonmota Hello vanderson, can you please review the tests I've made? They all pass, for now. I still plan to determine the min and max x,y based on SRID and set that accordingly. I've also needed to change get_required_values in the mommy class to set the required parameters. Oh, there's a catch, that I'm not sure how to solve: the testing database now needs to point to a PostGIS database. I'm sure we can change that to look for sqlite3 with spatial support, but that will not be optimum for all cases. We might need find a way to generate two database configurations, one with spatial support and other with no spatial support. Perhaps, that will need to be done inside the mommy class as well, I'm not sure if django will throw an error if the database backend does not have spatial support (even if it's just for testing). Please, let me know what you think. Later on I plan to extend this to support LineStrings and Polygons. |
Adding information about the spatial generators.
@george-silva I'm thinking that maybe spatial support should be better as an extension of model_mommy, since it handles a very specific case. It will be easier to test and will not burden model_mommy tests (setup a PostGIS) And it can be configured using: https://github.com/vandersonmota/model_mommy#custom-fields More thoughts? |
Ahhhhh! Great. It will be much easier to handle using custom fields. I'll see if I can revert the changes and create those extensions. |
Tell me when the extension is ready, so i'll add a reference in the README. |
Closing PR since it will be made as an extension. Let me know when you're done. Thanks! |
@george-silva Any news on adding this as an extension? I am definitely interested, as I am also using model mommy with a geospatial database... Thanks! |
@philippeluickx hello phillipe. Nice to see some interest. I'll see if I can do this today. |
@george-silva Cool! Good luck and thanks in advance! |
and @george-silva tell us when it's ready. I'll link to it on readme. Cheers! |
@philippeluickx and @vandersonmota : i did some quick changes and created a new repository for this extension. This needs packaging, but for now you can clone from git and it should be fine. Please let me know if this helped. https://github.com/sigma-consultoria/mommy_spatial_generators |
@george-silva Great, thanks for putting this up! |
Hello @vandersonmota.
This is a great project, but in my day to day work uses a lot of geospatial information, so I need model_mommy to generate spatial data as well.
This a first draft that includes a point generator, using the already consolidated formulaes used by model_mommy.
In here I've updated the association between a field type and generators and created the spatial generator.
perhaps there are other ways to handle this, but let me know.