Java Code Examples for mil.nga.geopackage.core.srs.SpatialReferenceSystemDao#create()

The following examples show how to use mil.nga.geopackage.core.srs.SpatialReferenceSystemDao#create() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoPackageExample.java    From geopackage-android with MIT License 5 votes vote down vote up
private static void createCrsWktExtension(GeoPackage geoPackage)
        throws SQLException {

    CrsWktExtension wktExtension = new CrsWktExtension(geoPackage);
    wktExtension.getOrCreate();

    SpatialReferenceSystemDao srsDao = geoPackage
            .getSpatialReferenceSystemDao();

    SpatialReferenceSystem srs = srsDao.queryForOrganizationCoordsysId(
            ProjectionConstants.AUTHORITY_EPSG,
            ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);

    SpatialReferenceSystem testSrs = new SpatialReferenceSystem();
    testSrs.setSrsName("test");
    testSrs.setSrsId(12345);
    testSrs.setOrganization("test_org");
    testSrs.setOrganizationCoordsysId(testSrs.getSrsId());
    testSrs.setDefinition(srs.getDefinition());
    testSrs.setDescription(srs.getDescription());
    testSrs.setDefinition_12_063(srs.getDefinition_12_063());
    srsDao.create(testSrs);

    SpatialReferenceSystem testSrs2 = new SpatialReferenceSystem();
    testSrs2.setSrsName("test2");
    testSrs2.setSrsId(54321);
    testSrs2.setOrganization("test_org");
    testSrs2.setOrganizationCoordsysId(testSrs2.getSrsId());
    testSrs2.setDefinition(srs.getDefinition());
    testSrs2.setDescription(srs.getDescription());
    srsDao.create(testSrs2);

}
 
Example 2
Source File: GeoPackageExample.java    From geopackage-java with MIT License 5 votes vote down vote up
private static void createCrsWktExtension(GeoPackage geoPackage)
		throws SQLException {

	CrsWktExtension wktExtension = new CrsWktExtension(geoPackage);
	wktExtension.getOrCreate();

	SpatialReferenceSystemDao srsDao = geoPackage
			.getSpatialReferenceSystemDao();

	SpatialReferenceSystem srs = srsDao.queryForOrganizationCoordsysId(
			ProjectionConstants.AUTHORITY_EPSG,
			ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);

	SpatialReferenceSystem testSrs = new SpatialReferenceSystem();
	testSrs.setSrsName("test");
	testSrs.setSrsId(12345);
	testSrs.setOrganization("test_org");
	testSrs.setOrganizationCoordsysId(testSrs.getSrsId());
	testSrs.setDefinition(srs.getDefinition());
	testSrs.setDescription(srs.getDescription());
	testSrs.setDefinition_12_063(srs.getDefinition_12_063());
	srsDao.create(testSrs);

	SpatialReferenceSystem testSrs2 = new SpatialReferenceSystem();
	testSrs2.setSrsName("test2");
	testSrs2.setSrsId(54321);
	testSrs2.setOrganization("test_org");
	testSrs2.setOrganizationCoordsysId(testSrs2.getSrsId());
	testSrs2.setDefinition(srs.getDefinition());
	testSrs2.setDescription(srs.getDescription());
	srsDao.create(testSrs2);

}
 
Example 3
Source File: SpatialReferenceSystemUtils.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Test create
 * 
 * @param geoPackage
 * @throws SQLException
 */
public static void testCreate(GeoPackage geoPackage) throws SQLException {

	SpatialReferenceSystemDao dao = geoPackage
			.getSpatialReferenceSystemDao();

	// Get current count
	long count = dao.countOf();

	String srsName = "TEST_SRS_NAME";
	long srsId = 123456l;
	String organization = "TEST_ORG";
	int organizationCoordSysId = 123456;
	String definition = "TEST_DEFINITION";
	String description = "TEST_DESCRIPTION";

	// Create new srs
	SpatialReferenceSystem srs = new SpatialReferenceSystem();
	srs.setSrsName(srsName);
	srs.setSrsId(srsId);
	srs.setOrganization(organization);
	srs.setOrganizationCoordsysId(organizationCoordSysId);
	srs.setDefinition(definition);
	srs.setDescription(description);
	dao.create(srs);

	// Verify count
	long newCount = dao.countOf();
	TestCase.assertEquals(count + 1, newCount);

	// Verify saved srs
	SpatialReferenceSystem querySrs = dao.queryForId(srsId);
	TestCase.assertEquals(srsName, querySrs.getSrsName());
	TestCase.assertEquals(srsId, querySrs.getSrsId());
	TestCase.assertEquals(organization, querySrs.getOrganization());
	TestCase.assertEquals(organizationCoordSysId,
			querySrs.getOrganizationCoordsysId());
	TestCase.assertEquals(definition, querySrs.getDefinition());
	TestCase.assertEquals(description, querySrs.getDescription());

	// Test copied srs
	SpatialReferenceSystem copySrs = new SpatialReferenceSystem(querySrs);
	TestCase.assertEquals(querySrs.getSrsName(), copySrs.getSrsName());
	TestCase.assertEquals(querySrs.getId(), copySrs.getId());
	TestCase.assertEquals(querySrs.getOrganization(),
			copySrs.getOrganization());
	TestCase.assertEquals(querySrs.getOrganizationCoordsysId(),
			copySrs.getOrganizationCoordsysId());
	TestCase.assertEquals(querySrs.getDefinition(), copySrs.getDefinition());
	TestCase.assertEquals(querySrs.getDescription(),
			copySrs.getDescription());
	TestCase.assertEquals(querySrs.getDefinition_12_063(),
			copySrs.getDefinition_12_063());

	// Change pk
	long copySrsId = 654321l;
	copySrs.setSrsId(copySrsId);

	dao.create(copySrs);

	// Verify count
	long newCount2 = dao.countOf();
	TestCase.assertEquals(count + 2, newCount2);

	// Verify saved contents
	SpatialReferenceSystem queryCopiedSrs = dao.queryForId(copySrsId);
	TestCase.assertEquals(querySrs.getSrsName(),
			queryCopiedSrs.getSrsName());
	TestCase.assertEquals(copySrsId, queryCopiedSrs.getSrsId());
	TestCase.assertEquals(querySrs.getOrganization(),
			queryCopiedSrs.getOrganization());
	TestCase.assertEquals(querySrs.getOrganizationCoordsysId(),
			queryCopiedSrs.getOrganizationCoordsysId());
	TestCase.assertEquals(querySrs.getDefinition(),
			queryCopiedSrs.getDefinition());
	TestCase.assertEquals(querySrs.getDescription(),
			queryCopiedSrs.getDescription());

}
 
Example 4
Source File: SpatialReferenceSystemUtils.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * Test create
 * 
 * @param geoPackage
 * @throws SQLException
 */
public static void testCreate(GeoPackage geoPackage) throws SQLException {

	SpatialReferenceSystemDao dao = geoPackage
			.getSpatialReferenceSystemDao();

	// Get current count
	long count = dao.countOf();

	String srsName = "TEST_SRS_NAME";
	long srsId = 123456l;
	String organization = "TEST_ORG";
	int organizationCoordSysId = 123456;
	String definition = "TEST_DEFINITION";
	String description = "TEST_DESCRIPTION";

	// Create new srs
	SpatialReferenceSystem srs = new SpatialReferenceSystem();
	srs.setSrsName(srsName);
	srs.setSrsId(srsId);
	srs.setOrganization(organization);
	srs.setOrganizationCoordsysId(organizationCoordSysId);
	srs.setDefinition(definition);
	srs.setDescription(description);
	dao.create(srs);

	// Verify count
	long newCount = dao.countOf();
	TestCase.assertEquals(count + 1, newCount);

	// Verify saved srs
	SpatialReferenceSystem querySrs = dao.queryForId(srsId);
	TestCase.assertEquals(srsName, querySrs.getSrsName());
	TestCase.assertEquals(srsId, querySrs.getSrsId());
	TestCase.assertEquals(organization, querySrs.getOrganization());
	TestCase.assertEquals(organizationCoordSysId,
			querySrs.getOrganizationCoordsysId());
	TestCase.assertEquals(definition, querySrs.getDefinition());
	TestCase.assertEquals(description, querySrs.getDescription());

	// Test copied srs
	SpatialReferenceSystem copySrs = new SpatialReferenceSystem(querySrs);
	TestCase.assertEquals(querySrs.getSrsName(), copySrs.getSrsName());
	TestCase.assertEquals(querySrs.getId(), copySrs.getId());
	TestCase.assertEquals(querySrs.getOrganization(),
			copySrs.getOrganization());
	TestCase.assertEquals(querySrs.getOrganizationCoordsysId(),
			copySrs.getOrganizationCoordsysId());
	TestCase.assertEquals(querySrs.getDefinition(), copySrs.getDefinition());
	TestCase.assertEquals(querySrs.getDescription(),
			copySrs.getDescription());
	TestCase.assertEquals(querySrs.getDefinition_12_063(),
			copySrs.getDefinition_12_063());

	// Change pk
	long copySrsId = 654321l;
	copySrs.setSrsId(copySrsId);

	dao.create(copySrs);

	// Verify count
	long newCount2 = dao.countOf();
	TestCase.assertEquals(count + 2, newCount2);

	// Verify saved contents
	SpatialReferenceSystem queryCopiedSrs = dao.queryForId(copySrsId);
	TestCase.assertEquals(querySrs.getSrsName(),
			queryCopiedSrs.getSrsName());
	TestCase.assertEquals(copySrsId, queryCopiedSrs.getSrsId());
	TestCase.assertEquals(querySrs.getOrganization(),
			queryCopiedSrs.getOrganization());
	TestCase.assertEquals(querySrs.getOrganizationCoordsysId(),
			queryCopiedSrs.getOrganizationCoordsysId());
	TestCase.assertEquals(querySrs.getDefinition(),
			queryCopiedSrs.getDefinition());
	TestCase.assertEquals(querySrs.getDescription(),
			queryCopiedSrs.getDescription());

}