Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add spoly(spoint[]) constructor function#99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

vitcpp
Copy link
Contributor

No description provided.

@vitcpp
Copy link
ContributorAuthor

After merge of#96, I will update the docs.

IMMUTABLE STRICT PARALLEL SAFE;

COMMENT ON FUNCTION spoly(spoint[]) IS
'Create spoly from an array of points.';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The comment should becreates spoly from an array of points (no capitalization, no period, and "creates" not "create") in order to match the other comments on the other functions.

vitcpp reacted with thumbs up emoji
'Create spoly from array of points.
Two consecutive numbers among those present
refer to the same occurrence and cover its
latitude and longitude, respectively.';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This doesn't match the comment on the same function in PR#96, so be prepared to resolve this conflict after PR#96 is merged. I don't believe multi-line comments work correctly, which is why I shortened it to one line. The second sentence is poorly phrased anyway, imho.

vitcpp reacted with thumbs up emoji
src/polygon.c Outdated
ArrayType *inarr = PG_GETARG_ARRAYTYPE_P(0);
SPoint *points;

np = ArrayGetNItems(ARR_NDIM(inarr), ARR_DIMS(inarr));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I propose combining this line with line 957 and just making it

intnp=ArrayGetNItems(ARR_NDIM(inarr),ARR_DIMS(inarr));

vitcpp reacted with thumbs up emoji
@@ -60,7 +60,7 @@ PG_FUNCTION_INFO_V1(spheretrans_poly_inverse);
PG_FUNCTION_INFO_V1(spherepoly_add_point);
PG_FUNCTION_INFO_V1(spherepoly_add_points_finalize);
PG_FUNCTION_INFO_V1(spherepoly_is_convex);

PG_FUNCTION_INFO_V1(spherepoly_from_point_array);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Just wondering why you didn't add this new function to polygon.h? I did in PR#96 and am wondering if I shouldn't have?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@esabol Function declaration in a header is needed when you use this function in another translation unit (.c file). You just include this header with function declarations to be able to use these functions without any compiler warnings. The spherepoly_from_point_array function is an interface function that is searched (ldsym) and called by postgresql. It is not used in other .c sources. Once, some other functions are defined in .h file, I will add the declaration.

Furthermore, pgindent requires "extern" modificator for functions declarations. I have some plans to use pgindent to reformat .h files to satisfy the postgresql coding style.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@vitcpp wrote:

Function declaration in a header is needed when you use this function in another translation unit (.c file).

Uh, yeah. I've been a professional C developer for over 28 years. I know what.h files are used for.

Inmy C projects, I put the prototype forevery function in its corresponding.h file. The only times I don't are when I'm working on an API library and I need to be concerned about which functions are in the public API and which are meant only to be used internally. And even then I'd probably create a separate internal-only.h file for the prototypes of internal functions. Anyway, that's just my development philosophy, I guess. Apparently, you have a different philosophy, and that's fine.

Basically, I just want to know if I should remove the prototype forspherepoly_deg that I added tosrc/polygon.h in PR#96. It sounds like I should!

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@esabol I'm sorry, I have no any intentions to teach anyone. I just wanted to clearly describe my position. My bad, a bucket with apples from me! :)

I agree with you to put the function declaration into .h file in pgsphere to follow the pgsphere code style. All other API functions are declared in .h files. I would also propose to add extern, but not in this PR. Pgindent will properly apply formatting to function declarations if it sees the extern keyword.

I will rebase and update my PR in according with your comments after the merge of#96.

esabol reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

OK, cool.

IMMUTABLE STRICT PARALLEL SAFE;

COMMENT ON FUNCTION spoly(spoint[]) IS
'Create spoly from an array of points.';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Change comment tocreates spoly from an array of points (no capitalization, no period, and "creates" not "create") in order to match the other comments on the other functions.

vitcpp reacted with thumbs up emoji
@esabolesabol mentioned this pull requestNov 1, 2023
sql/poly.sql Outdated

SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0)]);

SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10,10)]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nitpick: Change "10,10" to "10, 10".

vitcpp reacted with thumbs up emoji
sql/poly.sql Outdated

SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10,10)]);

SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10,10), spoint_deg(0, 10)]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nitpick: Change "10,10" to "10, 10".

vitcpp reacted with thumbs up emoji
src/polygon.c Outdated

if (np < 3)
{
elog(ERROR, "spoly_deg: invalid number of arguments (must be >= 3)");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Change "spoly_deg" to "spoly" (or "spherepoly_from_point_array"?).

vitcpp reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would propose to use the SQL function name but I'm not sure how to get the name from function arguments. Furthermore, such change should be done for other functions as well.

I would propose to use thefunc (C99) orFUNCTION macro but not sure that MSVC supports it. Lets keep the old approach now.

src/polygon.c Outdated

if (ARR_HASNULL(inarr))
{
elog(ERROR, "spoly_deg: input array is invalid because if has null values");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Change "spoly_deg" to "spoly" (or "spherepoly_from_point_array"?).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Also, please change "because if" to "because it" in this error message.

vitcpp reacted with thumbs up emoji
@vitcppvitcppforce-pushed thespoly_constructor_with_point_array branch from34132d3 toce73075CompareNovember 3, 2023 12:08
@vitcpp
Copy link
ContributorAuthor

vitcpp commentedNov 3, 2023
edited
Loading

Rebased, fixed problems after the review. The second commit will be squashed after completing the review.

@vitcppvitcppforce-pushed thespoly_constructor_with_point_array branch fromce73075 to595ecc9CompareNovember 3, 2023 13:07
@vitcpp
Copy link
ContributorAuthor

I updated the doc with the simple description of spoly and spoly_deg function. I used another approach to describe the functions to demonstrate some other approaches to describe functions. I didn't use funcsynopsis which is not suitable for describing SQL functions (funcsynopsis is for languages like C).

Copy link
Contributor

@esabolesabol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This looks good to me! Thank you so much for this contribution,@vitcpp !

vitcpp reacted with thumbs up emoji
@vitcppvitcpp merged commitb4a6fe4 intopostgrespro:masterNov 7, 2023
@vitcppvitcpp mentioned this pull requestNov 7, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@esabolesabolesabol approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@vitcpp@esabol

[8]ページ先頭

©2009-2025 Movatter.jp