-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Milestone
Description
I am just looking at the code with focus on the use of vtzero. Here are some things:
- https://github.com/mapbox/vtquery/blob/master/src/geometry_processors.hpp#L12 Why the check? Don't we want to reserve if
count == 1? - https://github.com/mapbox/vtquery/blob/master/src/geometry_processors.hpp#L29 can be const
- Consider rewriting the geometry processors to create the
mapbox::geometrytypes internally instead of taking them by reference and then returning it through theresult()function moving the result intoquery_geometry. (Look forresultin https://github.com/mapbox/vtzero/blob/master/doc/reading.md#geometries) - If you declare the copy/move constructors, always also declare copy/move assignment! https://github.com/mapbox/vtquery/blob/master/src/vtquery.cpp#L46-L50
- Comment is unclear: https://github.com/mapbox/vtquery/blob/master/src/vtquery.cpp#L49 If copy doesn't work anyway, you dont' need to specify the constructor anyway. But in this case I think what is meant is: "This is a huge object, make sure it never gets copied."
- Don't write comments that don't tell the reader anything more than the code already does. https://github.com/mapbox/vtquery/blob/master/src/vtquery.cpp#L33 . This just makes the code longer and it can easily get out of sync with the code when changes are made later.
- https://github.com/mapbox/vtquery/blob/master/src/vtquery.cpp#L134 creates an unnecessary
std::string. Something like this should work:{ const auto svalue = value.string_value(); return Nan::New<v8::String>(svalue.data(), svalue.size()).ToLocalChecked(); - The
execute()function is too long. https://github.com/mapbox/vtquery/blob/master/src/vtquery.cpp#L163-L294 Consider refactoring it, for instance by moving this part into its own function. Then comments like these https://github.com/mapbox/vtquery/blob/master/src/vtquery.cpp#L278-L280 are not needed any more. - Consider making https://github.com/mapbox/vtquery/blob/master/src/vtquery.cpp#L31 a
std::vector<vtzero::property>. It is unclear what https://github.com/mapbox/vtquery/blob/master/src/vtquery.cpp#L262-L268 is actually bying us. There are all these conversions tostd::string` why? - Use the type defined in https://github.com/mapbox/vtquery/blob/master/src/vtquery.cpp#L31 in https://github.com/mapbox/vtquery/blob/master/src/vtquery.cpp#L35 and https://github.com/mapbox/vtquery/blob/master/src/vtquery.cpp#L55 .
- What does the comment in https://github.com/mapbox/vtquery/blob/master/src/vtquery.cpp#L35 tell me? If I don't understand what an rvalue is, that comment is probably not going to help...
ResultObject,TileObjectandQueryDataare just structs. Consider making the code more object oriented and turn them into real classes. For instance this line https://github.com/mapbox/vtquery/blob/master/src/vtquery.cpp#L190 is somewhat confusing and parts of it at least could be a method onQueryDatacalledfind_layer_by_name()or so. Maybeutils::convert_vt_to_ll(https://github.com/mapbox/vtquery/blob/master/src/vtquery.cpp#L256) should be a method ofTileObject? It already takes three parameters from theTileObject.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels