Skip to content

"Trim Zeros" option turns decimals into integers #7451

@grantfitzsimmons

Description

@grantfitzsimmons

Describe the bug
Starting in v7.11.2, we are introducing a new feature where "trim zeros" can be applied to a field in a table format. This is fine, but this indicates to the user that they can trim zeros (which is most commonly requested in the case of latitude1 and longitude1, where leading zeros indicate false precision #1909). I tried to use this feature for this purpose, but found that it removed all data after the decimal point instead.

I created a Locality table format (included below), ran it on v7.11.2-prerelease (live on sp7demofish.specifycloud.org) and found that all data after the decimal point was lost. This should be resolved before release.

Failing

	<format name="dwc:footprintWKT" title="dwc:footprintWKT" class="edu.ku.brc.specify.datamodel.Locality" default="">
		<switch single="false" field="latLongType">
			<!-- POINT -->
			<fields value="Point">
				<field sep="POINT (" trimzeros="true">longitude1</field>
				<field sep=" " trimzeros="true">latitude1</field>
				<field>discipline.division.iconURI</field>
			</fields>
			<!-- LINESTRING -->
			<fields value="Line">
				<field sep="LINESTRING (" trimzeros="true">longitude1</field>
				<field sep=" " trimzeros="true">latitude1</field>
				<field sep=", " trimzeros="true">longitude2</field>
				<field sep=" " trimzeros="true">latitude2</field>
				<field>discipline.division.iconURI</field>
			</fields>
			<fields value="Rectangle">
				<field sep="POLYGON ((" trimzeros="true">longitude1</field>
				<field sep=", " trimzeros="true">longitude2</field>
				<field sep=" " trimzeros="true">latitude2</field>
				<field sep=", " trimzeros="true">longitude1</field>
				<field sep=" " trimzeros="true">latitude1</field>
				<field sep=")">discipline.division.iconURI</field>
			</fields>
		</switch>
	</format>
Image

Working

Image
	<format name="dwc:footprintWKT" title="dwc:footprintWKT" class="edu.ku.brc.specify.datamodel.Locality" default="">
		<switch single="false" field="latLongType">
			<!-- POINT -->
			<fields value="Point">
				<field sep="POINT (">longitude1</field>
				<field sep=" ">latitude1</field>
				<field sep="">discipline.division.iconURI</field>
			</fields>
			<!-- LINESTRING -->
			<fields value="Line">
				<field sep="LINESTRING (">longitude1</field>
				<field sep=" ">latitude1</field>
				<field sep=", ">longitude2</field>
				<field sep=" ">latitude2</field>
				<field sep="">discipline.division.iconURI</field>
			</fields>
			<fields value="Rectangle">
				<field sep="POLYGON ((">longitude1</field>
				<field sep=", ">longitude2</field>
				<field sep=" ">latitude2</field>
				<field sep=", ">longitude1</field>
				<field sep=" ">latitude1</field>
				<field sep=")">discipline.division.iconURI</field>
			</fields>
		</switch>
	</format>

Expected behavior
Best case scenario, this option should remove leading and trailing zeros, see #1909.
Acceptable resolution is to simply rename it "Trim Leading Zeros" instead of "Trim Zeros", but it should still not hide all data after the decimal point.

Metadata

Metadata

Assignees

No one assigned

    Labels

    regressionThis is behavior that once worked that has broken. Must be resolved before the next release.

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions