Opened 13 years ago
Closed 13 years ago
#3899 closed defect (invalid)
setPattern using Java MapScript-API throws "incorrect array size" error
Reported by: | rrenkert | Owned by: | unicoletti |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | MapScript-Java | Version: | svn-trunk (development) |
Severity: | normal | Keywords: | |
Cc: | sholl |
Description
When setting a pattern to a style using Java MapScript the following code throws an error:
--- style.setPatternlength(2); double[] values = new double[] {2.0, 2.0}; style.setPattern(values);
java.lang.IndexOutOfBoundsException: incorrect array size at edu.umn.gis.mapscript.mapscriptJNI.styleObj_pattern_set(Native Method) at edu.umn.gis.mapscript.styleObj.setPattern(styleObj.java:182) ---
The error occurs on different array sizes (tested with 3, 4, 5, 6 elements).
Thanks for fixing!
Regards
Raimund
Attachments (1)
Change History (3)
by , 13 years ago
Attachment: | PatternTest.java added |
---|
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
That is the expected result. The pattern array must be exactly 10 in length, like the following:
double[] vals = new double[] {2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0};
or:
double[] vals = new double[] {2.0, 2.0, 0, 0, 0, 0, 0, 0, 0, 0};
because pattern is declared as an array of 10:
double pattern[MS_MAXPATTERNLENGTH];
You can see that this is what is going on by browsing mapscript_wrap.c around line 8259 (mapserver version: trunk, with other versions the lineno might differ).
Closing as invalid.
for easy reproduction of the prpoblem I have added a simple testcase (PatternTest.java) for trying.
Thanks for looking into this.
Best