/** * gvSIG. Desktop Geographic Information System. * * Copyright (C) 2007-2021 gvSIG Association. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * For any additional information, do not hesitate to contact us * at info AT gvsig.com, or visit our website www.gvsig.com. */ package org.gvsig.topology.rule; import org.gvsig.fmap.geom.Geometry; import org.gvsig.json.Json; import org.gvsig.tools.util.ListBuilder; import org.gvsig.topology.lib.api.TopologyLocator; import org.gvsig.topology.lib.api.TopologyManager; import org.gvsig.topology.lib.api.TopologyRule; import org.gvsig.topology.lib.spi.AbstractTopologyRuleFactory; /** * * @author jjdelcerro */ @SuppressWarnings("UseSpecificCatch") public class PolygonMustNotOverlapWithPolygonRuleFactory extends AbstractTopologyRuleFactory { public static final String NAME = "PolygonMustNotOverlapWithPolygon"; public PolygonMustNotOverlapWithPolygonRuleFactory() { super( NAME, "Must Not Overlap With", "Requires that the interior of polygons in one feature class (or subtype) must not overlap with the interior of polygons in another feature class (or subtype). Polygons of the two feature classes can share edges or vertices or be completely disjointed. This rule is used when an area cannot belong to two separate feature classes. It is useful for combining two mutually exclusive systems of area classification, such as zoning and water body type, where areas defined within the zoning class cannot also be defined in the water body class and vice versa.", new ListBuilder() .add(Geometry.TYPES.SURFACE) .add(Geometry.TYPES.MULTISURFACE) .asList(), new ListBuilder() .add(Geometry.TYPES.SURFACE) .add(Geometry.TYPES.MULTISURFACE) .asList() ); } @Override public TopologyRule createRule(String dataSet1, String dataSet2, double tolerance) { TopologyRule rule = new PolygonMustNotOverlapWithPolygonRule(this, tolerance, dataSet1, dataSet2); return rule; } public static void selfRegister() { try { TopologyManager manager = TopologyLocator.getTopologyManager(); manager.addRuleFactories(new PolygonMustNotOverlapWithPolygonRuleFactory()); Json.registerSerializer(PolygonMustNotOverlapWithPolygonRule.class); } catch(Exception ex) { LOGGER.warn("Can't register topology rule from "+PolygonMustNotOverlapWithPolygonRuleFactory.class.getSimpleName(), ex); } } }