Hi,
in the ArcObjects SDK for Java, there is an example code to create a custom projected CS using IProjectedCoordinateSystemEdit define() method.
Here is the link:
How to create a custom projected coordinate system—ArcObjects 10.4 Help for Java | ArcGIS for Desktop
or ArcObjects Help for Java developers | ArcGIS for Desktop
Here is the example code:
static IProjectedCoordinateSystem createProjectedCoordinateSystem() throws Exception{
ISpatialReferenceFactory2 spatialReferenceFactory = new SpatialReferenceEnvironment();
//Create a projection, GeographicCoordinateSystem, and unit using the factory.
IProjectionGEN projection = (IProjectionGEN) spatialReferenceFactory.createProjection(
(int) esriSRProjectionType.esriSRProjection_Sinusoidal);
IGeographicCoordinateSystem geographicCoordinateSystem = spatialReferenceFactory.createGeographicCoordinateSystem(
(int) esriSRGeoCSType.esriSRGeoCS_WGS1984);
ILinearUnit unit = (ILinearUnit)spatialReferenceFactory.createUnit(
(int) esriSRUnitType.esriSRUnit_Meter);
//Get the default parameters from the projection.
IParameter[] parameters = projection.getDefaultParameters();
//Create a projected coordinate system using the Define method.
IProjectedCoordinateSystemEdit projectedCoordinateSystemEdit = new ProjectedCoordinateSystem();
Object name = "Newfoundland";
Object alias = "NF_LAB";
Object abbreviation = "NF";
Object remarks = "Most Eastern Province in Canada";
Object usage = "When making maps of Newfoundland";
Object geographicCoordinateSystemObject = geographicCoordinateSystem;
Object unitObject = unit;
Object projectionObject = projection;
Object parametersObject = parameters;
projectedCoordinateSystemEdit.define(name, alias, abbreviation, remarks, usage,
geographicCoordinateSystemObject, unitObject, projectionObject,
parametersObject); // <-- problem part. If I put null, then it works.
return (IProjectedCoordinateSystem)projectedCoordinateSystemEdit;
}
I've run the code, but wont work and throwing native library error: Execution protection violation.
Below I've attached the error log.
I've identified the problem part. The IParameter[] parameter is making the define() method crashes. If I substitute the parameter using null values, the define() method works perfectly.
I want to create a Lambert Azimuthal Equal Area PCS in which I can custumize the central latitude and longitude.
Thankyou,
I'm using:
ArcGIS Developer Kit 10.5
ArcGIS Engine 10.5
JDK ver. 1.8.0_151 32bit
JRE ver. 1.8.0_121 32bit (in the ArcGIS Developer Kit 10.5 folder)