GeoLatte / geolatte-geom

A geometry model that conforms to the OGC Simple Features for SQL specification.
Other
132 stars 63 forks source link

change CrsParameter, Extension, Projection to Serializable and fix bu… #135

Closed billtian closed 3 years ago

billtian commented 3 years ago

fix bug #132 when cache ProjectedCoordinateReferenceSystem

(cherry picked from commit 263e0f0c08077c3f6c35897a4e036fc1340b33ab)

maesenka commented 3 years ago

I had tested the serialization with a ProjectedCoordinateReferenceSystem and found no problems. What problems are you seeing that necessitated these changes?

I'd like to see a test that fails without this PR, so I can safeguard against future regressions

billtian commented 3 years ago

I had added a test testProjectedCrsCastToSerializable in SerializableTest . You will see java.io.NotSerializableException without this PR.

@Test
    public void testProjectedCrsCastToSerializable() throws IOException, ClassNotFoundException {
        ProjectedCoordinateReferenceSystem crs = CoordinateReferenceSystems.WEB_MERCATOR;

        Serializable ser = (Serializable) crs;
        File tempFile = Files.createTempFile("pcrs", ".ser").toFile();
        tempFile.deleteOnExit();
        try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(tempFile))){
            out.writeObject(crs);
        };

        ProjectedCoordinateReferenceSystem deser;
        try (ObjectInputStream ins = new ObjectInputStream(new FileInputStream(tempFile))) {
            deser = (ProjectedCoordinateReferenceSystem) ins.readObject();
        }

        assertEquals(crs, deser);

    }
maesenka commented 3 years ago

Sorry, you're absolutely correct! My mistake.

billtian commented 3 years ago

Its' Ok. Thanks for your work !