(*
 * $Id$
 *
 * JSDAI(TM), a way to implement STEP, ISO 10303
 * Copyright (C) 1997-2008, LKSoftWare GmbH, Germany
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License
 * version 3 as published by the Free Software Foundation (AGPL v3).
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * JSDAI is a registered trademark of LKSoftWare GmbH, Germany
 * This software is also available under commercial licenses.
 * See also http://www.jsdai.net/
 *)

(*schema_mapping location(Location_arm, Location_mim);*)
(*
uof_mapping -(-);
end_uof_mapping;
*)
(* AIM entity is taken instead
entity_mapping Address_based_location_representation(Address_based_location_representation, 
			address
		);

attribute_mapping postal_address(postal_address, $IDENTICAL_MAPPING, Address);

end_attribute_mapping;

end_entity_mapping;
*)
entity_mapping Location_armx(Location_armx, location);

attribute_mapping name(name, location.name);

					location
					location.name
				
end_attribute_mapping;

attribute_mapping description(description, location.description);

					location
					location.description
				
end_attribute_mapping;

attribute_mapping alternative_location_representations(alternative_location_representations, ($PATH)($PATH)($PATH)($PATH)($PATH), Location_representation);
(
						location
						location <-
						location_representation_assignment.represented_location
						location_representation_assignment =>
						applied_location_representation_assignment
						applied_location_representation_assignment.items[i] ->
						location_representation_item =
						representation
						{representation.name='global location representation'}
					)(
						location <-
						location_representation_assignment.represented_location
						location_representation_assignment =>
						applied_location_representation_assignment
						{applied_location_representation_assignment
						applied_location_representation_assignment.items[i] ->
						location_representation_item =
						organization}					
					)(
						location <-
						location_representation_assignment.represented_location
						location_representation_assignment =>
						applied_location_representation_assignment
						applied_location_representation_assignment.items[i] ->
						location_representation_item =
						address
					)(
						location <-
						location_representation_assignment.represented_location
						location_representation_assignment =>
						applied_location_representation_assignment
						{applied_location_representation_assignment
						applied_location_representation_assignment.items[i] ->
						location_representation_item =
						product}
					)(
						location =>
					characterized_location_object <=
					characterized_object =
					characterized_definition <-
					property_definition.definition
					property_definition =
					represented_definition <-
					property_definition_representation.definition
					property_definition_representation.used_representation ->
					representation
					{representation.name='regional grid location representation'}
					)
end_attribute_mapping;

end_entity_mapping;

entity_mapping Location_relationship_armx(Location_relationship_armx, location_relationship);

attribute_mapping name(name, location_relationship.name);

					location_relationship
					location_relationship.name
				
end_attribute_mapping;

attribute_mapping description(description, location_relationship.description);

					location_relationship
					location_relationship.description
				
end_attribute_mapping;

attribute_mapping related(related, $PATH, Location);

					location_relationship
					location_relationship.related_location ->
					location
				
end_attribute_mapping;

attribute_mapping relating(relating, $PATH, Location);

					location_relationship
					location_relationship.relating_location ->
					location
				
end_attribute_mapping;

end_entity_mapping;
(* In XIMs it became a select
entity_mapping Location_representation(Location_representation, (representation)(applied_location_representation_assignment)(
					address
				)(applied_location_representation_assignment)(representation));

mapping_constraints;
(
						representation
						{representation.name='global location representation'}
					)(
					applied_location_representation_assignment
					{applied_location_representation_assignment
					applied_location_representation_assignment.items[i] ->
					location_representation_item =
					organization}
				)(
						applied_location_representation_assignment
						{applied_location_representation_assignment
						applied_location_representation_assignment.items[i] ->
						location_representation_item =
						(product)
						(product_definition_formation)}
					)(
						representation
						{representation.name='regional grid location representation'}
					)
end_mapping_constraints;

end_entity_mapping;
*)
(* AIM enitity is taken instead
entity_mapping Classification_assignment(Classification_assignment, applied_classification_assignment)
extended;

attribute_mapping items(items, $PATH, Location_relationship);

					classification_item *>
					location_classification_item =
					location_relationship
				
end_attribute_mapping;

attribute_mapping items(items, $PATH, Location);

					classification_item *>
					location_classification_item =
					location
				
end_attribute_mapping;

end_entity_mapping;
*)
entity_mapping Global_location_representation(Global_location_representation, representation);

mapping_constraints;

				representation
				{representation.name='global location representation'}
			
end_mapping_constraints;

attribute_mapping geographical_area(geographical_area, representation_context.context_identifier);

					representation
					{representation.name='geographical representation'}
					representation.context_of_items ->
					representation_context
					representation_context.context_identifier
				
end_attribute_mapping;

attribute_mapping altitude(altitude, $PATH, measure_with_unit);

					representation
					representation.items[i] ->
					representation_item
					{representation_item.name='altitude'}
					representation_item =>
					measure_representation_item <=
					measure_with_unit
					{measure_with_unit =>
					length_measure_with_unit}
				
end_attribute_mapping;

attribute_mapping latitude(latitude, $PATH, measure_with_unit);

					representation
					representation.items[i] ->
					representation_item
					{representation_item.name='latitude'}
					representation_item =>
					measure_representation_item <=
					measure_with_unit
					{measure_with_unit =>
					plane_angle_measure_with_unit}
				
end_attribute_mapping;

attribute_mapping longitude(longitude, $PATH, measure_with_unit);

					representation
					representation.items[i] ->
					representation_item
					{representation_item.name='longitude'}
					representation_item =>
					measure_representation_item <=
					measure_with_unit
					{measure_with_unit =>
					plane_angle_measure_with_unit}
				
end_attribute_mapping;

end_entity_mapping;

entity_mapping Organization_based_location_representation_with_identification(Organization_based_location_representation_with_identification, applied_location_representation_assignment);

attribute_mapping organization_for_location(organization_for_location, $PATH, Organization);

					applied_location_representation_assignment
					{applied_location_representation_assignment
					applied_location_representation_assignment.items[i] ->
					location_representation_item =
					organization}
				
end_attribute_mapping;
(* merging 2 entities into one
attribute_mapping location_identifications(location_identifications, $IDENTICAL_MAPPING, applied_location_representation_assignment);

end_attribute_mapping;

end_entity_mapping;

entity_mapping Organizational_location_identification(Organizational_location_identification, applied_location_representation_assignment);

mapping_constraints;

				applied_location_representation_assignment
				{applied_location_representation_assignment
				applied_location_representation_assignment.items[i] ->
				location_representation_item =
				organization}
			
end_mapping_constraints;

attribute_mapping identification_type(identification_type, location_assignment.id);

					applied_location_representation_assignment <=
					location_representation_assignment
					location_representation_assignment.id
				
end_attribute_mapping;
*)
attribute_mapping location_value(location_value, location_assignment.name);

					applied_location_representation_assignment <=
					location_representation_assignment
					location_representation_assignment.name
				
end_attribute_mapping;

end_entity_mapping;

entity_mapping Product_based_location_identification(Product_based_location_identification, applied_location_representation_assignment);

mapping_constraints;

				applied_location_representation_assignment
				{applied_location_representation_assignment
				applied_location_representation_assignment.items[i] ->
				location_representation_item =
				(product)
				(product_definition_formation)}
			
end_mapping_constraints;

attribute_mapping referenced_product(referenced_product, $PATH, product_based_location_representation);

					applied_location_representation_assignment
					applied_location_representation_assignment.items[i] ->
					location_representation_item 
				
end_attribute_mapping;

attribute_mapping referenced_product(referenced_product, $PATH, Product);

					applied_location_representation_assignment
					applied_location_representation_assignment.items[i] ->
					location_representation_item =
					product
				
end_attribute_mapping;

attribute_mapping referenced_product(referenced_product, $PATH, product_definition_formation);

					applied_location_representation_assignment
					applied_location_representation_assignment.items[i] ->
					location_representation_item =
					product_definition_formation
				
end_attribute_mapping;

attribute_mapping location_identification(location_identification, location_assignment.id);

					applied_location_representation_assignment <=
					location_representation_assignment
					location_representation_assignment.id
				
end_attribute_mapping;

attribute_mapping location_name(location_name, location_assignment.name);

					applied_location_representation_assignment <=
					location_representation_assignment
					location_representation_assignment.name
				
end_attribute_mapping;

end_entity_mapping;

entity_mapping Regional_coordinate(Regional_coordinate, measure_representation_item);

attribute_mapping name(name, representation_item.name);

					measure_representation_item <=
					representation_item
					representation_item.name
				
end_attribute_mapping;
(* This attribute is removed from XIMs as it is redundant
attribute_mapping coordinate_value(coordinate_value, $PATH, measure_with_unit);

					measure_representation_item
					measure_representation_item <=
					measure_with_unit
				
end_attribute_mapping;
*)
attribute_mapping grid_system(grid_system, $PATH, Regional_grid_location_representation);

					measure_representation_item <=
					representation_item <-
					representation.items[i]
					representation
					{representation.name='regional grid location representation'}
				
end_attribute_mapping;

end_entity_mapping;

entity_mapping Regional_grid_location_representation(Regional_grid_location_representation, representation);

mapping_constraints;

				representation
				{representation.name='regional grid location representation'}
			
end_mapping_constraints;

attribute_mapping name(name, representation.id);

					representation
					{representation.name='regional grid location representation'}
					representation.id
				
end_attribute_mapping;

attribute_mapping description(description, );

					representation
					{representation.name='regional grid location representation'}
					representation.description
				
end_attribute_mapping;

end_entity_mapping;
(*end_schema_mapping;*)
