Create a shapefile using Java Mapscript

Sean Gillies sgillies at FRII.COM
Wed Apr 27 15:21:58 EDT 2005


On Apr 27, 2005, at 1:10 PM, Dan Barron wrote:

> I seem to seeing the exact same issue with writing a shapefile of
> points
> via java mapscript - though at one point it did work.
>
> What's the trick to "closing" the shapfeilObj file in java mapscript?
> I am
> using ms 4.4.0 java mapscript.
>
> Thanks,
>
> Dan
>
> At 06:49 AM 4/21/2005, you wrote:
>> On Apr 21, 2005, at 6:43 AM, Libo Feng wrote:
>>
>>> I am a newbie to Java mapscript and in my project, I need to
>>> dynamically
>>> create a shape file that contains a point. The coordinate of that
>>> point is
>>> from an address matching web service. I am able to create the .shp,
>>> .shx
>>> files with the mapscript and a .dbf file with Javadbf. But the .shp
>>> and .shx
>>> seem to be empty - when I open it with ArcExplorer, there is no point
>>> at all.
>>>
>>> The following is the code:
>>>
>>> shapefileObj civicAddressShp = new shapefileObj(shapeFile,
>>>
>>> mapscriptConstants.MS_SHAPEFILE_POINT);
>>> pointObj addressPoint = new pointObj(x, y, 0.0, Double.MIN_VALUE);
>>> civicAddressShp.addPoint(addressPoint);
>>>
>>>
>>> Did I miss anything? Thanks!
>>
>> Yes, what you missed is that the point isn't written to the file on
>> disk until the shapefileObj is "closed".  The only way to close it is
>> by triggering its destructor.  It's awkward, but that's just the way
>> it
>> is.
>>
>> cheers,
>> Sean
>>

delete the shapefileObj instance.

Sean



More information about the mapserver-users mailing list