Ticket #324 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

Theme widget doesn't work because layer definition schema definition

Reported by: christinebao Owned by: Christine Bao
Priority: P2 Milestone: Future
Component: Widgets Version: 1.1.1
Severity: Major Keywords: Theme
Cc: Chris Claydon External ID: 1276805
state: New Browser: All
Operating System: All

Description

Steps to reproduce:

Scenario 1:
1. Load the attached bayarea_cities.sdf, let's name the layer as layer1.LayerDefinition?.
2. Create a map based on layer1.LayerDefinition? using default setting, and create a flexible web layout based on the map using default setting. Let's name the web as web1.ApplicationDefinition.
3. Open web1 in browser, choose Theme widget, using the default setting, and Apply.

Result: Nothing happens. The map is not themed.

Scenario 2:
1. Load the attached bayarea_cities.sdf, let's name the layer as layer2.LayerDefinition?. Make some change in layer2.LayerDefinition?, for example, choose "OBJECTID" as Tooltips displayed for feature.
2. Create a map based on layer2.LayerDefinition? using default setting, and create a flexible web layout based on the map using default setting. Let's name the web as web2.ApplicationDefinition.
3. Open web2 in browser, choose Theme widget, using the default setting, and Apply.

Result: The map is themed.

Attachments

bayarea_cities.sdf Download (0.6 MB) - added by christinebao 4 years ago.
Ticket#324.patch Download (2.4 KB) - added by christinebao 4 years ago.
RefineTicket#324.patch Download (2.4 KB) - added by christinebao 4 years ago.

Change History

Changed 4 years ago by christinebao

Changed 4 years ago by christinebao

Tech diagnosis:

The key point is the original layer definition. Please use MapAgent? / GetResourceContent? to check the layer definitioins. Please pay special attention to the element <AreaTypeStyle?>.
In layer1.LayerDefinition?, it's:

<AreaTypeStyle>
	<AreaRule>
		...
	</AreaRule>
	<ShowInLegend>true</ShowInLegend>
</AreaTypeStyle>


And in layer2.LayerDefinition? it's:

<AreaTypeStyle>
	<AreaRule>
		...
	</AreaRule>
</AreaTypeStyle>


The difference is layer1.LayerDefinition? contains additional element <ShowInLegend?> besides <AreaRule?>, while layer2.LayerDefinition? doesn't.

How this defect happens?
The theme widget works in this way:
1. Remove the existing <AreaRule?>.
2. Create a series of new <AreaRule?> based on user's setting.
3. Append the new <AreaRule?> to <AreaTypeStyle?>.

LayerDefinition?-1.3.0.xsd defines <AreaTypeStyle?> in this way:

 <xs:complexType name="AreaTypeStyleType">
    <xs:annotation>
      <xs:documentation>Style specification of a polygon geometry type.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="AreaRule" type="AreaRuleType" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>Rules to define a theme.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ShowInLegend" type="xs:boolean" default="true" minOccurs="0"/>
      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>


It requires <AreaRule?> must be ahead of <ShowInLegend?>.

In scenario 1, because new <AreaRule?> is appended to <AreaTypeStyle?>, and it goes after <ShowInLegend?>, an exception throws out when saving to DB XML.
In scenario 2, the above problem doesn't exist, so it works.

How to fix?
theme.php function ApplyTheme?(): should decide whether <AreaTypeStyle?> has additional element besides <AreaRule?>. If yes, the new <AreaRule?> should insert into first node. If no the new <AreaRule?> should be appended.

Changed 4 years ago by christinebao

Changed 4 years ago by christinebao

Changed 4 years ago by christinebao

Changed 4 years ago by christinebao

Refine the patch by http://trac.osgeo.org/fusion/attachment/ticket/324/RefineTicket%23324.patch.

The new area rule should be inserted by order, otherwise the legend will be disordered.

Changed 4 years ago by christinebao

  • status changed from new to closed
  • resolution set to fixed

Commit the patch to fix defect.

Note: See TracTickets for help on using tickets.